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

Comparing deliantra/server/server/build_map.C (file contents):
Revision 1.12 by root, Tue Dec 12 21:39:57 2006 UTC vs.
Revision 1.68 by root, Mon Oct 29 23:55:55 2012 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
4 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
8 it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
9 the Free Software Foundation; either version 2 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
10 (at your option) any later version. 11 * option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
18 along with this program; if not, write to the Free Software 19 * and the GNU General Public License along with this program. If not, see
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * <http://www.gnu.org/licenses/>.
20 21 *
21 The authors can be reached via e-mail to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#include <living.h> 26#include <living.h>
26#include <spells.h> 27#include <spells.h>
27#include <skills.h> 28#include <skills.h>
28#include <tod.h> 29#include <tod.h>
29#include <sproto.h> 30#include <sproto.h>
30 31
32// macro for this check, it had been inconsistent in this file.
33#define IS_FLOOR(x) x->flag [FLAG_IS_FLOOR]
34
31/** 35/**
32 * Check if objects on a square interfere with building 36 * Check if objects on a square interfere with building
33 */ 37 */
34int 38static int
35can_build_over (maptile *map, object *tmp, short x, short y) 39can_build_over (maptile *map, object *tmp, int x, int y)
36{ 40{
37 object *ob; 41 object *ob;
38 42
39 ob = GET_MAP_OB (map, x, y); 43 ob = GET_MAP_OB (map, x, y);
40 while (ob) 44 while (ob)
41 { 45 {
42 /* if ob is not a marking rune or floor, then check special cases */ 46 /* if ob is not a marking rune or floor, then check special cases */
43 if (strcmp (ob->arch->name, "rune_mark") && ob->type != FLOOR) 47 if (ob->arch->archname != shstr_rune_mark && !IS_FLOOR (ob))
44 { 48 {
45 switch (tmp->type) 49 switch (tmp->type)
46 { 50 {
47 case SIGN: 51 case SIGN:
48 case MAGIC_EAR: 52 case MAGIC_EAR:
49 /* Allow signs and magic ears to be built on books */ 53 /* Allow signs and magic ears to be built on books */
50 if (ob->type != BOOK) 54 if (ob->type != BOOK)
51 {
52 return 0;
53 }
54 break;
55 case BUTTON:
56 case DETECTOR:
57 case PEDESTAL:
58 case CF_HANDLE:
59 /* Allow buttons and levers to be built under gates */
60 if (ob->type != GATE && ob->type != DOOR)
61 {
62 return 0;
63 }
64 break;
65 default:
66 return 0; 55 return 0;
56 break;
57 case BUTTON:
58 case DETECTOR:
59 case PEDESTAL:
60 case T_HANDLE:
61 /* Allow buttons and levers to be built under gates */
62 if (ob->type != GATE && ob->type != DOOR)
63 return 0;
64 break;
65 default:
66 return 0;
67 } 67 }
68 } 68 }
69
69 ob = ob->above; 70 ob = ob->above;
70 } 71 }
72
71 return 1; 73 return 1;
72} 74}
73 75
74/** 76/**
75 * Erases marking runes at specified location 77 * Erases marking runes at specified location
76 */ 78 */
77void 79static void
78remove_marking_runes (maptile *map, short x, short y) 80remove_marking_runes (maptile *map, int x, int y)
79{ 81{
80 object *rune; 82 object *rune;
81 object *next; 83 object *next;
82 84
83 rune = GET_MAP_OB (map, x, y); 85 rune = GET_MAP_OB (map, x, y);
84 while (rune) 86 while (rune)
85 { 87 {
86 next = rune->above; 88 next = rune->above;
87 89
88 if ((rune->type == SIGN) && (!strcmp (rune->arch->name, "rune_mark"))) 90 if (rune->type == SIGN && rune->arch->archname == shstr_rune_mark)
89 rune->destroy (); 91 rune->destroy ();
90 92
91 rune = next; 93 rune = next;
92 } 94 }
93} 95}
97 * \param map: map for which to find a value 99 * \param map: map for which to find a value
98 * \return 'connected' value with no item, or -1 if failure. 100 * \return 'connected' value with no item, or -1 if failure.
99 * 101 *
100 * Tries 1000 random values, then returns -1. 102 * Tries 1000 random values, then returns -1.
101 */ 103 */
102int 104static shstr_tmp
103find_unused_connected_value (maptile *map) 105find_unused_connected_value (maptile *map)
104{ 106{
105 int connected = 0; 107 for (int i = 1000; --i; )
106 int itest = 0;
107 oblinkpt *obp;
108
109 while (itest++ < 1000)
110 {
111 connected = 1 + rand () % 20000;
112 for (obp = map->buttons; obp && (obp->value != connected); obp = obp->next);
113
114 if (!obp)
115 return connected;
116 } 108 {
109 char buf[64];
117 110
111 snprintf (buf, sizeof (buf), "built-%x", rndm (0xf0000000U) + 0x10000000U);
112
113 shstr id (buf);
114
115 if (!map->find_link (id))
116 return id;
117 }
118
119 return shstr_tmp ();
120}
121
122/**
123 * Returns the marking rune on the square, for purposes of building connections
124 */
125static object *
126get_connection_rune (object *pl, int x, int y)
127{
128 object *rune = GET_MAP_OB (pl->map, x, y);
129
130 while (rune && (rune->type != SIGN || rune->arch->archname != shstr_rune_mark))
131 rune = rune->above;
132
118 return -1; 133 return rune;
119} 134}
120
121 135
122/** 136/**
123 * Helper function for door/button/connected item building. 137 * Helper function for door/button/connected item building.
124 * 138 *
125 * Will search the specified spot for a marking rune. 139 * Will search the specified spot for a marking rune.
127 * Else, searches a force in op's inventory matching the map's name 141 * Else, searches a force in op's inventory matching the map's name
128 * and the rune's text. 142 * and the rune's text.
129 * If found, returns the connection value associated 143 * If found, returns the connection value associated
130 * else searches a new connection value, and adds the force to the player. 144 * else searches a new connection value, and adds the force to the player.
131 */ 145 */
132int 146static shstr_tmp
133find_or_create_connection_for_map (object *pl, short x, short y, object *rune) 147find_or_create_connection_for_map (object *pl, int x, int y, object *rune)
134{ 148{
135 object *force; 149 object *force;
136 int connected;
137 150
138 if (!rune) 151 if (!rune)
139 rune = get_connection_rune (pl, x, y); 152 rune = get_connection_rune (pl, x, y);
140 153
141 if (!rune) 154 if (!rune)
142 { 155 {
143 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a marking rune with the group name."); 156 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a marking rune with the group name.");
144 return -1; 157 return shstr_tmp ();
145 } 158 }
146 159
147 /* Now, find force in player's inventory */ 160 /* Now, find force in player's inventory */
148 force = pl->inv; 161 force = pl->inv;
149 while (force 162 while (force
150 && ((force->type != FORCE) || (!force->slaying) || (strcmp (force->slaying, pl->map->path)) || (!force->msg) 163 && ((force->type != FORCE) || !force->slaying || force->slaying != pl->map->path || !force->msg
151 || (strcmp (force->msg, rune->msg)))) 164 || force->msg != rune->msg))
152 force = force->below; 165 force = force->below;
153 166
154 if (!force) 167 if (!force)
155 /* No force, need to create & insert one */ 168 /* No force, need to create & insert one */
156 { 169 {
157 /* Find unused value */ 170 /* Find unused value */
158 connected = find_unused_connected_value (pl->map); 171 shstr_tmp id = find_unused_connected_value (pl->map);
159 if (connected == -1) 172
173 if (!id)
160 { 174 {
161 new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups."); 175 new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups.");
162 return -1; 176 return shstr_tmp ();
163 } 177 }
164 178
165 force = get_archetype (FORCE_NAME); 179 force = archetype::get (FORCE_NAME);
166 force->speed = 0;
167 update_ob_speed (force);
168 force->slaying = pl->map->path; 180 force->slaying = pl->map->path;
169 force->msg = rune->msg; 181 force->msg = rune->msg;
170 force->path_attuned = connected; 182 force->race = id;
183 force->set_speed (0);
184
171 insert_ob_in_ob (force, pl); 185 insert_ob_in_ob (force, pl);
172 186
173 return connected; 187 return id;
174 } 188 }
175 189
176 /* Found the force, everything's easy. */ 190 /* Found the force, everything's easy. */
177 return force->path_attuned; 191 return force->race;
178}
179
180/**
181 * Returns the marking rune on the square, for purposes of building connections
182 */
183object *
184get_connection_rune (object *pl, short x, short y)
185{
186 object *rune;
187
188 rune = GET_MAP_OB (pl->map, x, y);
189 while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->name, "rune_mark"))))
190 rune = rune->above;
191 return rune;
192} 192}
193 193
194/** 194/**
195 * Returns the book/scroll on the current square, for purposes of building 195 * Returns the book/scroll on the current square, for purposes of building
196 */ 196 */
197object * 197static object *
198get_msg_book (object *pl, short x, short y) 198get_msg_book (object *pl, int x, int y)
199{ 199{
200 object *book;
201
202 book = GET_MAP_OB (pl->map, x, y); 200 object *book = GET_MAP_OB (pl->map, x, y);
201
203 while (book && (book->type != BOOK)) 202 while (book && (book->type != BOOK))
204 book = book->above; 203 book = book->above;
204
205 return book; 205 return book;
206} 206}
207 207
208/** 208/**
209 * Make the built object inherit the msg of books that are used with it.
210 * For objects already invisible (i.e. magic mouths & ears), also make it
211 * it inherit the face and the name with "talking " prepended.
212 */
213static int
214adjust_sign_msg (object *pl, int x, int y, object *tmp)
215{
216 object *book;
217 char buf[MAX_BUF];
218 char buf2[MAX_BUF];
219
220 book = get_msg_book (pl, x, y);
221 if (!book)
222 {
223 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a book or scroll with the message.");
224 return -1;
225 }
226
227 if (tmp->type == MAGIC_EAR)
228 {
229 snprintf (buf, sizeof (buf), "@match %s", &(book->msg));
230 tmp->msg = buf;
231 }
232 else
233 tmp->msg = book->msg;
234
235 if (tmp->invisible)
236 {
237 if (book->custom_name)
238 snprintf (buf, sizeof (buf), "talking %s", &book->custom_name);
239 else
240 snprintf (buf, sizeof (buf), "talking %s", &book->name);
241
242 tmp->name = buf;
243
244 if (book->name_pl)
245 {
246 snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl);
247 tmp->name_pl = buf2;
248 }
249
250 tmp->face = book->face;
251 tmp->invisible = 0;
252 }
253
254 book->destroy ();
255 return 0;
256}
257
258/**
209 * Returns first item of type WALL. 259 * Returns first item of type BUILDABLE_WALL.
210 */ 260 */
211object * 261static object *
212get_wall (maptile *map, int x, int y) 262get_wall (maptile *map, int x, int y)
213{ 263{
214 object *wall;
215
216 wall = GET_MAP_OB (map, x, y); 264 object *wall = GET_MAP_OB (map, x, y);
265
217 while (wall && (WALL != wall->type)) 266 while (wall && (BUILDABLE_WALL != wall->type))
218 wall = wall->above; 267 wall = wall->above;
219 268
220 return wall; 269 return wall;
221} 270}
222 271
229 * 278 *
230 * Basically it ensures the correct wall is put where needed. 279 * Basically it ensures the correct wall is put where needed.
231 * 280 *
232 * Note: x & y must be valid map coordinates. 281 * Note: x & y must be valid map coordinates.
233 */ 282 */
234void 283static void
235fix_walls (maptile *map, int x, int y) 284fix_walls (maptile *map, int x, int y)
236{ 285{
237 int connect;
238 object *wall;
239 char archetype[MAX_BUF]; 286 char archetype[MAX_BUF];
240 char *underscore; 287 char *underscore;
241 uint32 old_flags[4];
242 struct archetype *new_arch; 288 struct archetype *new_arch;
243 int flag;
244
245 289
246 /* First, find the wall on that spot */ 290 /* First, find the wall on that spot */
247 wall = get_wall (map, x, y); 291 object *wall = get_wall (map, x, y);
248 if (!wall) 292 if (!wall)
249 /* Nothing -> bail out */ 293 /* Nothing -> bail out */
250 return; 294 return;
251 295
252 /* Find base name */ 296 /* Find base name */
253 strcpy (archetype, wall->arch->name); 297 assign (archetype, wall->arch->archname);
254 underscore = strchr (archetype, '_'); 298 underscore = strchr (archetype, '_');
255 299
256 /* search for the first _ before a number */ 300 /* search for the first _ before a number */
257 while (underscore && !isdigit (*(underscore + 1))) 301 while (underscore && !isdigit (*(underscore + 1)))
258 underscore = strchr (underscore + 1, '_'); 302 underscore = strchr (underscore + 1, '_');
262 return; 306 return;
263 307
264 underscore++; 308 underscore++;
265 *underscore = '\0'; 309 *underscore = '\0';
266 310
267 connect = 0; 311 int connect = 0;
268 312
269 if ((x > 0) && get_wall (map, x - 1, y)) 313 if (x > 0 && get_wall (map, x - 1, y)) connect |= 1;
270 connect |= 1; 314 if (x < map->width - 1 && get_wall (map, x + 1, y)) connect |= 2;
271 if ((x < MAP_WIDTH (map) - 1) && get_wall (map, x + 1, y)) 315 if (y > 0 && get_wall (map, x, y - 1)) connect |= 4;
272 connect |= 2; 316 if (y < map->height - 1 && get_wall (map, x, y + 1)) connect |= 8;
273 317
274 if ((y > 0) && get_wall (map, x, y - 1)) 318 strcat (archetype, wall_suffix [connect]);
275 connect |= 4;
276
277 if ((y < MAP_HEIGHT (map) - 1) && get_wall (map, x, y + 1))
278 connect |= 8;
279
280 switch (connect)
281 {
282 case 0:
283 strcat (archetype, "0");
284
285 break;
286 case 1:
287 strcat (archetype, "1_3");
288
289 break;
290 case 2:
291 strcat (archetype, "1_4");
292
293 break;
294 case 3:
295 strcat (archetype, "2_1_2");
296
297 break;
298 case 4:
299 strcat (archetype, "1_2");
300
301 break;
302 case 5:
303 strcat (archetype, "2_2_4");
304
305 break;
306 case 6:
307 strcat (archetype, "2_2_1");
308
309 break;
310 case 7:
311 strcat (archetype, "3_1");
312
313 break;
314 case 8:
315 strcat (archetype, "1_1");
316
317 break;
318 case 9:
319 strcat (archetype, "2_2_3");
320
321 break;
322 case 10:
323 strcat (archetype, "2_2_2");
324
325 break;
326 case 11:
327 strcat (archetype, "3_3");
328
329 break;
330 case 12:
331 strcat (archetype, "2_1_1");
332
333 break;
334 case 13:
335 strcat (archetype, "3_4");
336
337 break;
338 case 14:
339 strcat (archetype, "3_2");
340
341 break;
342 case 15:
343 strcat (archetype, "4");
344
345 break;
346 }
347 319
348 /* 320 /*
349 * Before anything, make sure the archetype does exist... 321 * Before anything, make sure the archetype does exist...
350 * If not, prolly an error... 322 * If not, prolly an error...
351 */ 323 */
355 return; 327 return;
356 328
357 /* Now delete current wall, and insert new one 329 /* Now delete current wall, and insert new one
358 * We save flags to avoid any trouble with buildable/non buildable, and so on 330 * We save flags to avoid any trouble with buildable/non buildable, and so on
359 */ 331 */
360 for (flag = 0; flag < 4; flag++) 332 object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off
361 old_flags[flag] = wall->flags[flag];
362 333
363 wall->destroy (); 334 wall->destroy ();
364 335
365 wall = arch_to_object (new_arch); 336 wall = new_arch->instance ();
366 wall->type = WALL; 337 wall->type = BUILDABLE_WALL;
367 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); 338 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y);
368 for (flag = 0; flag < 4; flag++)
369 wall->flags[flag] = old_flags[flag]; 339 wall->flag = old_flags;
370} 340}
371 341
372/** 342/**
373 * \brief Floor building function 343 * \brief Floor building function
374 * 344 *
377 * - on an existing wall, with or without a floor under it 347 * - on an existing wall, with or without a floor under it
378 * 348 *
379 * Note: this function will inconditionally change squares around (x, y) 349 * Note: this function will inconditionally change squares around (x, y)
380 * so don't call it with x == 0 for instance! 350 * so don't call it with x == 0 for instance!
381 */ 351 */
382void 352static void
383apply_builder_floor (object *pl, object *material, short x, short y) 353apply_builder_floor (object *pl, object *material, int x, int y)
384{ 354{
385 object *tmp, *above; 355 object *tmp, *above;
386 object *above_floor; /* Item above floor, if any */ 356 object *above_floor; /* Item above floor, if any */
387 struct archetype *new_floor; 357 struct archetype *new_floor;
388 struct archetype *new_wall; 358 struct archetype *new_wall;
402 if (tmp) 372 if (tmp)
403 { 373 {
404 while (tmp) 374 while (tmp)
405 { 375 {
406 above = tmp->above; 376 above = tmp->above;
407 if (WALL == tmp->type) 377 if (BUILDABLE_WALL == tmp->type)
408 { 378 {
409 /* There was a wall, remove it & keep its archetype to make new walls */ 379 /* There was a wall, remove it & keep its archetype to make new walls */
410 new_wall = tmp->arch; 380 new_wall = tmp->arch;
411 tmp->destroy (); 381 tmp->destroy ();
412 sprintf (message, "You destroy the wall and redo the floor."); 382 sprintf (message, "You destroy the wall and redo the floor.");
413 } 383 }
414 else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) 384 else if (IS_FLOOR (tmp))
415 { 385 {
416 tmp->destroy (); 386 tmp->destroy ();
417 floor_removed = 1; 387 floor_removed = 1;
418 } 388 }
419 else 389 else
420 { 390 {
421 if (floor_removed) 391 if (floor_removed)
392 {
393 /* This is the first item that was above the floor */
422 above_floor = tmp; 394 above_floor = tmp;
395 floor_removed = 0;
396 }
423 } 397 }
424 398
425 tmp = above; 399 tmp = above;
426 } 400 }
427 } 401 }
433 /* Not found, log & bail out */ 407 /* Not found, log & bail out */
434 LOG (llevError, "apply_builder_floor: unable to find archetype %s.\n", &material->slaying); 408 LOG (llevError, "apply_builder_floor: unable to find archetype %s.\n", &material->slaying);
435 return; 409 return;
436 } 410 }
437 411
438 tmp = arch_to_object (new_floor); 412 tmp = new_floor->instance ();
439 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 413 tmp->set_flag (FLAG_IS_BUILDABLE);
440 SET_FLAG (tmp, FLAG_UNIQUE); 414 tmp->set_flag (FLAG_UNIQUE);
441 SET_FLAG (tmp, FLAG_IS_FLOOR); 415 tmp->set_flag (FLAG_IS_FLOOR);
442 tmp->type = FLOOR; 416 //tmp->type = FLOOR;
443 insert_ob_in_map_at (tmp, pl->map, above_floor, above_floor ? INS_BELOW_ORIGINATOR : INS_ON_TOP, x, y); 417 insert_ob_in_map_at (tmp, pl->map, above_floor, above_floor ? INS_BELOW_ORIGINATOR : INS_ON_TOP, x, y);
444 418
445 /* 419 /*
446 * Next step: make sure there are either walls or floors around the new square 420 * Next step: make sure there are either walls or floors around the new square
447 * Since building, you can have: blocking view / floor / wall / nothing 421 * Since building, you can have: blocking view / floor / wall / nothing
452 yt = y + freearr_y[i]; 426 yt = y + freearr_y[i];
453 tmp = GET_MAP_OB (pl->map, xt, yt); 427 tmp = GET_MAP_OB (pl->map, xt, yt);
454 if (!tmp) 428 if (!tmp)
455 { 429 {
456 /* Must insert floor & wall */ 430 /* Must insert floor & wall */
457 tmp = arch_to_object (new_floor); 431 tmp = new_floor->instance ();
458 /* Better make the floor unique */ 432 /* Better make the floor unique */
459 SET_FLAG (tmp, FLAG_UNIQUE); 433 tmp->set_flag (FLAG_UNIQUE);
460 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 434 tmp->set_flag (FLAG_IS_BUILDABLE);
461 tmp->type = FLOOR; 435 //tmp->type = FLOOR;
462 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); 436 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt);
463 /* Insert wall if exists. Note: if it doesn't, the map is weird... */ 437 /* Insert wall if exists. Note: if it doesn't, the map is weird... */
464 if (new_wall) 438 if (new_wall)
465 { 439 {
466 tmp = arch_to_object (new_wall); 440 tmp = new_wall->instance ();
467 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 441 tmp->set_flag (FLAG_IS_BUILDABLE);
468 tmp->type = WALL; 442 tmp->type = BUILDABLE_WALL;
469 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); 443 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt);
470 } 444 }
471 } 445 }
472 } 446 }
473 447
475 * Note: 2 squares around are checked, because potentially we added walls around the building 449 * Note: 2 squares around are checked, because potentially we added walls around the building
476 * spot, so need to check that those new walls connect correctly 450 * spot, so need to check that those new walls connect correctly
477 */ 451 */
478 for (xt = x - 2; xt <= x + 2; xt++) 452 for (xt = x - 2; xt <= x + 2; xt++)
479 for (yt = y - 2; yt <= y + 2; yt++) 453 for (yt = y - 2; yt <= y + 2; yt++)
480 {
481 if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) 454 if (!OUT_OF_REAL_MAP (pl->map, xt, yt))
482 fix_walls (pl->map, xt, yt); 455 fix_walls (pl->map, xt, yt);
483 }
484 456
485 /* Now remove raw item from inventory */ 457 /* Now remove raw item from inventory */
486 decrease_ob (material); 458 material->decrease ();
487 459
488 /* And tell player about the fix */ 460 /* And tell player about the fix */
489 new_draw_info (NDI_UNIQUE, 0, pl, message); 461 new_draw_info (NDI_UNIQUE, 0, pl, message);
490}
491
492/**
493 * Wall radius fix function
494 */
495void fix_walls_around (maptile *map, int x, int y)
496{
497 for (int xt = x - 1; xt <= x + 1; xt++)
498 for (int yt = y - 1; yt <= y + 1; yt++)
499 {
500 if (OUT_OF_REAL_MAP (map, xt, yt))
501 continue;
502
503 fix_walls (map, xt, yt);
504 }
505} 462}
506 463
507/** 464/**
508 * Wall building function 465 * Wall building function
509 * 466 *
510 * Walls can be build: 467 * Walls can be build:
511 * - on a floor without anything else 468 * - on a floor without anything else
512 * - on an existing wall, with or without a floor 469 * - on an existing wall, with or without a floor
513 */ 470 */
514void 471static void
515apply_builder_wall (object *pl, object *material, short x, short y) 472apply_builder_wall (object *pl, object *material, int x, int y)
516{ 473{
517 object *current_wall; 474 object *current_wall;
518 object *tmp; 475 object *tmp;
519 int xt, yt; 476 int xt, yt;
520 struct archetype *new_wall; 477 struct archetype *new_wall;
525 /* Grab existing wall, if any */ 482 /* Grab existing wall, if any */
526 current_wall = NULL; 483 current_wall = NULL;
527 tmp = GET_MAP_OB (pl->map, x, y); 484 tmp = GET_MAP_OB (pl->map, x, y);
528 while (tmp && !current_wall) 485 while (tmp && !current_wall)
529 { 486 {
530 if (WALL == tmp->type) 487 if (BUILDABLE_WALL == tmp->type)
531 current_wall = tmp; 488 current_wall = tmp;
532 489
533 tmp = tmp->above; 490 tmp = tmp->above;
534 } 491 }
535 492
542 { 499 {
543 LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying); 500 LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying);
544 return; 501 return;
545 } 502 }
546 503
547 tmp = arch_to_object (new_wall); 504 tmp = new_wall->instance ();
548 tmp->type = WALL; 505 tmp->type = BUILDABLE_WALL;
549 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 506 tmp->set_flag (FLAG_IS_BUILDABLE);
550 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); 507 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y);
551 508
552 /* If existing wall, remove it, no need to fix other walls */ 509 /* If existing wall, remove it, no need to fix other walls */
553 if (current_wall) 510 if (current_wall)
554 { 511 {
568 fix_walls (pl->map, xt, yt); 525 fix_walls (pl->map, xt, yt);
569 } 526 }
570 } 527 }
571 528
572 /* Now remove item from inventory */ 529 /* Now remove item from inventory */
573 decrease_ob (material); 530 material->decrease ();
574 531
575 /* And tell player what happened */ 532 /* And tell player what happened */
576 new_draw_info (NDI_UNIQUE, 0, pl, message); 533 new_draw_info (NDI_UNIQUE, 0, pl, message);
577} 534}
578 535
582 * Item must be put on a square with a floor, you can have something under. 539 * Item must be put on a square with a floor, you can have something under.
583 * Archetype of created object is item->slaying (raw material). 540 * Archetype of created object is item->slaying (raw material).
584 * Type of inserted item is tested for specific cases (doors & such). 541 * Type of inserted item is tested for specific cases (doors & such).
585 * Item is inserted above the floor, unless Str == 1 (only for detectors i guess) 542 * Item is inserted above the floor, unless Str == 1 (only for detectors i guess)
586 */ 543 */
587void 544static void
588apply_builder_item (object *pl, object *item, short x, short y) 545apply_builder_item (object *pl, object *item, int x, int y)
589{ 546{
590 object *tmp; 547 object *tmp;
591 struct archetype *arch; 548 struct archetype *arch;
592 int insert_flag; 549 int insert_flag;
593 object *floor; 550 object *floor;
594 object *con_rune; 551 object *con_rune;
595 int connected;
596 552
597 /* Find floor */ 553 /* Find floor */
598 floor = GET_MAP_OB (pl->map, x, y); 554 floor = GET_MAP_OB (pl->map, x, y);
599 if (!floor) 555 if (!floor)
600 { 556 {
601 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); 557 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square.");
602 return; 558 return;
603 } 559 }
604 560
605 while (floor && (floor->type != FLOOR) && (!QUERY_FLAG (floor, FLAG_IS_FLOOR))) 561 while (floor && !IS_FLOOR (floor))
606 floor = floor->above; 562 floor = floor->above;
607 563
608 if (!floor) 564 if (!floor)
609 { 565 {
610 new_draw_info (NDI_UNIQUE, 0, pl, "This square has no floor, you can't build here."); 566 new_draw_info (NDI_UNIQUE, 0, pl, "This square has no floor, you can't build here.");
613 /* Create item, set flag, insert in map */ 569 /* Create item, set flag, insert in map */
614 arch = archetype::find (item->slaying); 570 arch = archetype::find (item->slaying);
615 if (!arch) 571 if (!arch)
616 return; 572 return;
617 573
618 tmp = arch_to_object (arch); 574 tmp = arch->instance ();
619 575
620 if ((floor->above) && (!can_build_over (pl->map, tmp, x, y))) 576 if (!floor->flag[FLAG_IS_BUILDABLE] || floor->above && !can_build_over (pl->map, tmp, x, y))
621 /* Floor has something on top that interferes with building */ 577 /* Floor has something on top that interferes with building */
622 { 578 {
623 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); 579 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here.");
624 return; 580 return;
625 } 581 }
626 582
627 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 583 tmp->set_flag (FLAG_IS_BUILDABLE);
628 SET_FLAG (tmp, FLAG_NO_PICK); 584 tmp->set_flag (FLAG_NO_PICK);
629 585
630 /* 586 /*
631 * This doesn't work on non unique maps. pedestals under floor will not be saved... 587 * Str 1 is a flag that the item [pedestal] should go below the floor.
632 insert_flag = ( item->stats.Str == 1 ) ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY; 588 * Items under the floor on non-unique maps will not be saved,
589 * so make the item itself unique in this situation.
633 */ 590 */
634 insert_flag = INS_ABOVE_FLOOR_ONLY; 591 insert_flag = item->stats.Str == 1 ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY;
592 if (insert_flag == INS_BELOW_ORIGINATOR && !pl->map->no_reset)
593 tmp->set_flag (FLAG_UNIQUE);
635 594
636 connected = 0; 595 shstr_tmp connected;
596
637 switch (tmp->type) 597 switch (tmp->type)
638 { 598 {
639 case DOOR: 599 case DOOR:
640 case GATE: 600 case GATE:
641 case BUTTON: 601 case BUTTON:
642 case DETECTOR: 602 case DETECTOR:
643 case TIMED_GATE: 603 case TIMED_GATE:
644 case PEDESTAL: 604 case PEDESTAL:
645 case CF_HANDLE: 605 case T_HANDLE:
646 case MAGIC_EAR: 606 case MAGIC_EAR:
647 case SIGN: 607 case SIGN:
648 /* Signs don't need a connection, but but magic mouths do. */ 608 /* Signs don't need a connection, but but magic mouths do. */
649 if (tmp->type == SIGN && strcmp (tmp->arch->name, "magic_mouth")) 609 if (tmp->type == SIGN && tmp->arch->archname != shstr_magic_mouth)
650 break; 610 break;
611
651 con_rune = get_connection_rune (pl, x, y); 612 con_rune = get_connection_rune (pl, x, y);
652 connected = find_or_create_connection_for_map (pl, x, y, con_rune); 613 connected = find_or_create_connection_for_map (pl, x, y, con_rune);
653 if (connected == -1) 614 if (!connected)
654 { 615 {
655 /* Player already informed of failure by the previous function */ 616 /* Player already informed of failure by the previous function */
656 tmp->destroy (); 617 tmp->destroy ();
657 return; 618 return;
658 } 619 }
620
659 /* Remove marking rune */ 621 /* Remove marking rune */
660 con_rune->destroy (); 622 con_rune->destroy ();
661 } 623 }
662 624
663 /* For magic mouths/ears, and signs, take the msg from a book of scroll */ 625 /* For magic mouths/ears, and signs, take the msg from a book of scroll */
664 if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) 626 if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR))
665 {
666 if (adjust_sign_msg (pl, x, y, tmp) == -1) 627 if (adjust_sign_msg (pl, x, y, tmp) == -1)
667 { 628 {
668 tmp->destroy (); 629 tmp->destroy ();
669 return; 630 return;
670 } 631 }
671 }
672 632
673 insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); 633 insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y);
674 if (connected != 0) 634 if (connected)
675 add_button_link (tmp, pl->map, connected); 635 tmp->add_link (pl->map, connected);
676 636
677 new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp)); 637 new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp));
678 decrease_ob_nr (item, 1); 638 item->decrease ();
679} 639}
680 640
681/** 641/**
682 * Item remover. 642 * Item remover.
683 * 643 *
684 * Removes first buildable item, either under or above the floor 644 * Removes first buildable item, either under or above the floor
685 */ 645 */
686void 646static void
687apply_builder_remove (object *pl, int dir) 647apply_builder_remove (object *pl, int dir)
688{ 648{
689 object *item; 649 object *item;
690 short x, y; 650 int x, y;
691 651
692 x = pl->x + freearr_x[dir]; 652 x = pl->x + freearr_x[dir];
693 y = pl->y + freearr_y[dir]; 653 y = pl->y + freearr_y[dir];
694 654
695 /* Check square */ 655 /* Check square */
696 item = GET_MAP_OB (pl->map, x, y); 656 item = GET_MAP_OB (pl->map, x, y);
697 if (!item) 657 if (!item)
698 { 658 {
699 /* Should not happen with previous tests, but we never know */ 659 /* Should not happen with previous tests, but we never know */
700 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); 660 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square.");
701 LOG (llevError, "apply_builder_remove: (null) square at (%d, %d, %s)\n", x, y, pl->map->path); 661 LOG (llevError, "apply_builder_remove: (null) square at (%d, %d, %s)\n", x, y, &pl->map->path);
702 return; 662 return;
703 } 663 }
704 664
705 if (item->type == FLOOR || QUERY_FLAG (item, FLAG_IS_FLOOR)) 665 if (IS_FLOOR (item))
706 item = item->above; 666 item = item->above;
707 667
708 if (!item) 668 if (!item)
709 {
710 new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove."); 669 new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove.");
670 else if (item->type == BUILDABLE_WALL)
671 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor.");
672 else if (!item->flag [FLAG_IS_BUILDABLE])
673 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item));
674 else
675 {
676 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item));
677 item->destroy ();
678 }
679}
680
681
682static void
683replace_open_space_floor (object *os, object *material)
684{
685 object *new_floor = archetype::get (material->slaying);
686 insert_ob_in_map_at (new_floor, os->map, os,
687 INS_BELOW_ORIGINATOR, os->x, os->y);
688 os->destroy ();
689 material->decrease ();
690}
691
692/**
693 * Quad building.
694 */
695void
696apply_builder_quad (object *pl, object *material, mapxy &pos)
697{
698 object *open_space = 0;
699 object *floor = 0;
700
701 object *tmp = pos.ms ().bot;
702 bool floor_exists = false;
703 while (tmp)
704 {
705 if (floor_exists && tmp->flag [FLAG_IS_QUAD])
706 {
707 pl->failmsg (
708 "You can't build there, there is a block in the way.");
709 return;
710 }
711
712 if (IS_FLOOR (tmp))
713 {
714 floor = tmp;
715 floor_exists = true;
716
717 if (floor->arch->archname == shstr_quad_open_space)
718 {
719 open_space = floor;
720 }
721 else if (!floor->flag [FLAG_IS_QUAD])
722 {
723 pl->failmsg (
724 "You can't build there, the floor is not suited.");
725 return;
726 }
727 }
728
729 tmp = tmp->above;
730 }
731
732 if (open_space)
733 {
734 if (!material->slaying)
735 {
736 pl->failmsg (
737 "The floor is open and you can't fill it with that material."
738 "H<Use another material to fill the ceiling.>");
739 return;
740 }
741
742 replace_open_space_floor (open_space, material);
743 pl->contr->fire_on = 0; // TODO: stopgap, do not add more than one per keypress
711 return; 744 return;
712 } 745 }
713 746 else if (floor)
714 /* Now remove object, with special cases (buttons & such) */
715 switch (item->type)
716 { 747 {
717 case WALL: 748
718 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); 749 maptile *upper_floor = pos.m->tile_available (TILE_UP);
750 if (!upper_floor)
751 {
752 pl->failmsg (
753 "Whoops, you can't see the ceiling.. H<You may try again.>");
719 return; 754 return;
755 }
720 756
721 case DOOR: 757 mapxy above_pos (upper_floor, pos.x, pos.y);
722 case BUTTON: 758 if (!above_pos.normalise ())
723 case GATE: 759 {
724 case TIMED_GATE: 760 pl->failmsg (
725 case DETECTOR: 761 "Whoops, you can't access the ceiling. H<You may try again.>");
726 case PEDESTAL: 762 return;
727 case CF_HANDLE: 763 }
728 case MAGIC_EAR:
729 case SIGN:
730 /* Special case: must unconnect */
731 if (QUERY_FLAG (item, FLAG_IS_LINKED))
732 remove_button_link (item);
733 764
734 /* Fall through */ 765 mapspace &above_ms = above_pos.ms ();
766 for (object *quad_obj = above_ms.top; quad_obj; quad_obj = quad_obj->below)
767 {
768 if (quad_obj->arch->archname == shstr_quad_open_space)
769 {
770 if (!material->slaying)
771 {
772 pl->failmsg (
773 "The ceiling is open and you can't fill it with that material."
774 "H<Use another material to fill the ceiling.>");
775 return;
776 }
735 777
736 default: 778 replace_open_space_floor (quad_obj, material);
737 /* Remove generic item */ 779 break;
738 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); 780 }
739 item->destroy (); 781 }
782
783 if (material->destroyed ())
784 {
785 pl->failmsg (
786 "You don't have enough build material to build a wall here.");
787 return;
788 }
789
790 object *quad_wall = material->other_arch->instance ();
791 material->decrease ();
792
793 insert_ob_in_map_at (quad_wall, floor->map, 0,
794 INS_ABOVE_FLOOR_ONLY, floor->x, floor->y);
795 }
796 else
797 {
798 pl->failmsg ("You can't build a quad block here.");
740 } 799 }
741} 800}
742 801
743/** 802/**
744 * Global building function 803 * Global building function
747 * or remover object. 806 * or remover object.
748 */ 807 */
749void 808void
750apply_map_builder (object *pl, int dir) 809apply_map_builder (object *pl, int dir)
751{ 810{
752 object *builder;
753 object *tmp;
754 object *tmp2;
755 short x, y;
756
757 if (!pl->type == PLAYER) 811 if (!pl->type == PLAYER)
758 return; 812 return;
759 813
760 /*if ( !player->map->unique )
761 {
762 new_draw_info( NDI_UNIQUE, 0, player, "You can't build outside a unique map." );
763 return;
764 } */
765
766 if (dir == 0) 814 if (dir == 0)
767 { 815 {
768 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build or destroy under yourself."); 816 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build or destroy under yourself.");
769 return; 817 return;
770 } 818 }
771 819
772 x = pl->x + freearr_x[dir]; 820 mapxy pos (pl); pos.move (dir);
773 y = pl->y + freearr_y[dir];
774 821
775 if ((1 > x) || (1 > y) || ((MAP_WIDTH (pl->map) - 2) < x) || ((MAP_HEIGHT (pl->map) - 2) < y)) 822 if (!pos.normalise ())
776 { 823 {
777 new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge..."); 824 pl->failmsg ("You can't build here. H<There is nothing in this direction.>");
778 return; 825 return;
779 } 826 }
780 827
781 /* 828 /*
782 * Check specified square 829 * Check specified square
783 * The square must have only buildable items 830 * The square must have only buildable items
784 * Exception: marking runes are all right, 831 * Exception: marking runes are all right,
785 * since they are used for special things like connecting doors / buttons 832 * since they are used for special things like connecting doors / buttons
786 */ 833 */
787 834
788 tmp = GET_MAP_OB (pl->map, x, y); 835 object *builder = pl->contr->ranged_ob;
789 if (!tmp) 836
790 { 837 object *tmp2 = pl->mark ();
791 /* Nothing, meaning player is standing next to an undefined square... */ 838
792 LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, pl->map->path); 839 object *tmp = 0;
793 new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird."); 840 for (tmp = pos.ms ().bot; tmp; tmp = tmp->above)
794 return;
795 } 841 {
796 tmp2 = find_marked_object (pl); 842 if (!tmp->flag [FLAG_IS_BUILDABLE]
797 while (tmp) 843 && (tmp->type != SIGN || tmp->arch->archname != shstr_rune_mark))
798 {
799 if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && ((tmp->type != SIGN) || (strcmp (tmp->arch->name, "rune_mark"))))
800 { 844 {
801 /* The item building function already has it's own special 845 /* The item building function already has it's own special
802 * checks for this 846 * checks for this. And so does the quad building function.
803 */ 847 */
804 if ((!tmp2) || (tmp2->subtype != ST_MAT_ITEM)) 848 if (!tmp2 || (tmp2->subtype != ST_MAT_ITEM && tmp2->subtype != ST_MAT_QUAD))
805 { 849 {
850 if (!INVOKE_PLAYER (BUILD, pl->contr, ARG_OBJECT (builder),
851 ARG_MAP (pl->map),
852 ARG_INT (pos.y), ARG_INT (pos.y),
853 ARG_INT (0)))
806 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); 854 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here.");
855
807 return; 856 return;
808 } 857 }
809 } 858 }
810 tmp = tmp->above;
811 } 859 }
812 860
813 /* Now we know the square is ok */ 861 /* Now we know the square is ok */
814 builder = pl->contr->ranges[range_builder]; 862 if (INVOKE_PLAYER (BUILD, pl->contr, ARG_OBJECT (builder),
863 ARG_MAP (pl->map), ARG_INT (pos.x), ARG_INT (pos.y), ARG_INT (1)))
864 return;
815 865
816 if (builder->subtype == ST_BD_REMOVE) 866 if (builder->subtype == ST_BD_REMOVE)
817 /* Remover -> call specific function and bail out */ 867 /* Remover -> call specific function and bail out */
818 { 868 {
819 apply_builder_remove (pl, dir); 869 apply_builder_remove (pl, dir);
839 return; 889 return;
840 } 890 }
841 891
842 switch (tmp->subtype) 892 switch (tmp->subtype)
843 { 893 {
844 case ST_MAT_FLOOR: 894 case ST_MAT_FLOOR:
845 apply_builder_floor (pl, tmp, x, y); 895 apply_builder_floor (pl, tmp, pos.x, pos.y);
846 return; 896 return;
847 897
848 case ST_MAT_WALL: 898 case ST_MAT_WALL:
849 apply_builder_wall (pl, tmp, x, y); 899 apply_builder_wall (pl, tmp, pos.x, pos.y);
850 return; 900 return;
851 901
852 case ST_MAT_ITEM: 902 case ST_MAT_ITEM:
853 apply_builder_item (pl, tmp, x, y); 903 apply_builder_item (pl, tmp, pos.x, pos.y);
854 return; 904 return;
855 905
906 case ST_MAT_QUAD:
907 apply_builder_quad (pl, tmp, pos);
908 return;
909
856 default: 910 default:
857 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this material, sorry."); 911 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this material, sorry.");
858 LOG (llevError, "apply_map_builder: invalid material subtype %d\n", tmp->subtype); 912 LOG (llevError, "apply_map_builder: invalid material subtype %d\n", tmp->subtype);
859 return; 913 return;
860 } 914 }
861 } 915 }
862 916
863 /* Here, it means the builder has an invalid type */ 917 /* Here, it means the builder has an invalid type */
864 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this tool, sorry."); 918 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this tool, sorry.");
865 LOG (llevError, "apply_map_builder: invalid builder subtype %d\n", builder->subtype); 919 LOG (llevError, "apply_map_builder: invalid builder subtype %d\n", builder->subtype);
866} 920}
867 921
868/**
869 * Make the built object inherit the msg of books that are used with it.
870 * For objects already invisible (i.e. magic mouths & ears), also make it
871 * it inherit the face and the name with "talking " prepended.
872 */
873int
874adjust_sign_msg (object *pl, short x, short y, object *tmp)
875{
876 object *book;
877 char buf[MAX_BUF];
878 char buf2[MAX_BUF];
879
880 book = get_msg_book (pl, x, y);
881 if (!book)
882 {
883 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a book or scroll with the message.");
884 return -1;
885 }
886
887 tmp->msg = book->msg;
888
889 if (tmp->invisible)
890 {
891 if (book->custom_name != NULL)
892 {
893 snprintf (buf, sizeof (buf), "talking %s", &book->custom_name);
894 }
895 else
896 {
897 snprintf (buf, sizeof (buf), "talking %s", &book->name);
898 }
899 tmp->name = buf;
900
901 if (book->name_pl != NULL)
902 {
903 snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl);
904 tmp->name_pl = buf2;
905 }
906
907 tmp->face = book->face;
908 tmp->invisible = 0;
909 }
910
911 book->destroy ();
912 return 0;
913}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines