… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * 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 |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * 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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * 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 |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <unistd.h> |
25 | #include <unistd.h> |
… | |
… | |
334 | if (IN_RANGE_EXC (op->x, 0, width) && IN_RANGE_EXC (op->y, 0, height)) |
335 | if (IN_RANGE_EXC (op->x, 0, width) && IN_RANGE_EXC (op->y, 0, height)) |
335 | { |
336 | { |
336 | // we insert manually because |
337 | // we insert manually because |
337 | // a) its way faster |
338 | // a) its way faster |
338 | // b) we remove manually, too, and there are good reasons for that |
339 | // b) we remove manually, too, and there are good reasons for that |
339 | // c) its correct |
340 | // c) it's correct |
340 | mapspace &ms = at (op->x, op->y); |
341 | mapspace &ms = at (op->x, op->y); |
341 | |
342 | |
342 | op->flag [FLAG_REMOVED] = false; |
343 | op->flag [FLAG_REMOVED] = false; |
343 | |
344 | |
344 | op->above = 0; |
345 | op->above = 0; |
345 | op->below = ms.top; |
346 | op->below = ms.top; |
346 | |
347 | |
347 | if (ms.top) |
|
|
348 | ms.top->above = op; |
348 | *(ms.top ? &ms.top->above : &ms.bot) = op; |
349 | else |
|
|
350 | ms.bot = op; |
|
|
351 | |
349 | |
352 | ms.top = op; |
350 | ms.top = op; |
353 | ms.flags_ = 0; |
351 | ms.flags_ = 0; |
354 | } |
352 | } |
355 | else |
353 | else |
… | |
… | |
937 | op->destroy (); |
935 | op->destroy (); |
938 | } |
936 | } |
939 | } |
937 | } |
940 | |
938 | |
941 | /* |
939 | /* |
942 | * Updates every button on the map (by calling update_button() for them). |
|
|
943 | */ |
|
|
944 | void |
|
|
945 | maptile::update_buttons () |
|
|
946 | { |
|
|
947 | for (oblinkpt *obp = buttons; obp; obp = obp->next) |
|
|
948 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
|
|
949 | { |
|
|
950 | if (!ol->ob) |
|
|
951 | { |
|
|
952 | LOG (llevError, "Internal error in update_button (%s (%dx%d), connected %ld).\n", |
|
|
953 | ol->ob ? (const char *) ol->ob->name : "null", ol->ob ? ol->ob->x : -1, ol->ob ? ol->ob->y : -1, obp->value); |
|
|
954 | continue; |
|
|
955 | } |
|
|
956 | |
|
|
957 | if (ol->ob->type == BUTTON || ol->ob->type == PEDESTAL) |
|
|
958 | { |
|
|
959 | update_button (ol->ob); |
|
|
960 | break; |
|
|
961 | } |
|
|
962 | } |
|
|
963 | } |
|
|
964 | |
|
|
965 | /* |
|
|
966 | * This routine is supposed to find out the difficulty of the map. |
940 | * This routine is supposed to find out the difficulty of the map. |
967 | * difficulty does not have a lot to do with character level, |
941 | * difficulty does not have a lot to do with character level, |
968 | * but does have a lot to do with treasure on the map. |
942 | * but does have a lot to do with treasure on the map. |
969 | * |
943 | * |
970 | * Difficulty can now be set by the map creator. If the value stored |
944 | * Difficulty can now be set by the map creator. If the value stored |
… | |
… | |
1542 | else |
1516 | else |
1543 | { |
1517 | { |
1544 | retval->distance_x += op2->x - x; |
1518 | retval->distance_x += op2->x - x; |
1545 | retval->distance_y += op2->y - y; |
1519 | retval->distance_y += op2->y - y; |
1546 | |
1520 | |
1547 | retval->part = NULL; |
1521 | retval->part = 0; |
1548 | retval->distance = idistance (retval->distance_x, retval->distance_y); |
1522 | retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); |
1549 | retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); |
1523 | retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); |
1550 | } |
1524 | } |
1551 | } |
1525 | } |
1552 | |
1526 | |
1553 | /* Returns true of op1 and op2 are effectively on the same map |
1527 | /* Returns true of op1 and op2 are effectively on the same map |
… | |
… | |
1628 | if (distance <= MAX_SOUND_DISTANCE) |
1602 | if (distance <= MAX_SOUND_DISTANCE) |
1629 | ns->play_sound (sound, dx, dy); |
1603 | ns->play_sound (sound, dx, dy); |
1630 | } |
1604 | } |
1631 | } |
1605 | } |
1632 | |
1606 | |
|
|
1607 | void |
|
|
1608 | maptile::say_msg (const char *msg, int x, int y) const |
|
|
1609 | { |
|
|
1610 | for_all_players (pl) |
|
|
1611 | if (client *ns = pl->ns) |
|
|
1612 | { |
|
|
1613 | int dx = x - pl->ob->x; |
|
|
1614 | int dy = y - pl->ob->y; |
|
|
1615 | |
|
|
1616 | int distance = idistance (dx, dy); |
|
|
1617 | |
|
|
1618 | if (distance <= MAX_SOUND_DISTANCE) |
|
|
1619 | ns->send_msg (NDI_GREY | NDI_DEF, SAY_CHANNEL, msg); |
|
|
1620 | } |
|
|
1621 | } |
|
|
1622 | |
1633 | static void |
1623 | static void |
1634 | split_to_tiles (dynbuf &buf, maptile *m, int x0, int y0, int x1, int y1, int dx, int dy) |
1624 | split_to_tiles (dynbuf &buf, maptile *m, int x0, int y0, int x1, int y1, int dx, int dy) |
1635 | { |
1625 | { |
1636 | // clip to map to the left |
1626 | // clip to map to the left |
1637 | if (x0 < 0) |
1627 | if (x0 < 0) |