1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 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 it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
80 | { |
80 | { |
81 | LOG (llevError, "blocked_link: Passed map, x, y coordinates outside of map\n"); |
81 | LOG (llevError, "blocked_link: Passed map, x, y coordinates outside of map\n"); |
82 | return 1; |
82 | return 1; |
83 | } |
83 | } |
84 | |
84 | |
85 | /* Save some cycles - instead of calling get_map_flags(), just get the value |
|
|
86 | * directly. |
|
|
87 | */ |
|
|
88 | mapspace &ms = m->at (sx, sy); |
85 | mapspace &ms = m->at (sx, sy); |
89 | |
86 | |
90 | int mflags = ms.flags (); |
87 | int mflags = ms.flags (); |
91 | int blocked = ms.move_block; |
88 | int blocked = ms.move_block; |
92 | |
89 | |
93 | /* If space is currently not blocked by anything, no need to |
90 | /* If space is currently not blocked by anything, no need to |
94 | * go further. Not true for players - all sorts of special |
91 | * go further. Not true for players - all sorts of special |
95 | * things we need to do for players. |
92 | * things we need to do for players. |
… | |
… | |
114 | * true. If we get through the entire stack, that must mean |
111 | * true. If we get through the entire stack, that must mean |
115 | * ob is blocking it, so return 0. |
112 | * ob is blocking it, so return 0. |
116 | */ |
113 | */ |
117 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
114 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
118 | { |
115 | { |
119 | /* This must be before the checks below. Code for inventory checkers. */ |
116 | if (OB_MOVE_BLOCK (ob, tmp)) |
120 | if (tmp->type == CHECK_INV && OB_MOVE_BLOCK (ob, tmp)) |
|
|
121 | { |
117 | { |
122 | bool have = check_inv_recursive (ob, tmp); |
118 | if (INVOKE_OBJECT (BLOCKED_MOVE, tmp, ob)) |
123 | |
119 | if (RESULT_INT (0)) |
124 | /* If last_sp is set, the player/monster needs an object, |
120 | return 1; |
125 | * so we check for it. If they don't have it, they can't |
|
|
126 | * pass through this space. |
|
|
127 | */ |
121 | else |
128 | if (tmp->last_sp) |
122 | continue; |
|
|
123 | |
|
|
124 | if (tmp->type == CHECK_INV) |
129 | { |
125 | { |
130 | if (!have) |
126 | bool have = check_inv_recursive (ob, tmp); |
|
|
127 | |
|
|
128 | // last_sp set means we block if we don't have. |
|
|
129 | if (logical_xor (have, tmp->last_sp)) |
|
|
130 | return 1; |
|
|
131 | } |
|
|
132 | else if (tmp->type == T_MATCH) |
|
|
133 | { |
|
|
134 | // T_MATCH allows "entrance" iff the match is true |
|
|
135 | // == blocks if the match fails |
|
|
136 | |
|
|
137 | // we could have used an INVOKE_OBJECT, but decided against it, as we |
|
|
138 | // assume that T_MATCH is relatively common. |
|
|
139 | if (!match (tmp->slaying, ob, tmp, ob)) |
131 | return 1; |
140 | return 1; |
132 | } |
141 | } |
133 | else |
142 | else |
134 | { |
143 | return 1; // unconditional block |
135 | /* In this case, the player must not have the object - |
144 | |
136 | * if they do, they can't pass through. |
|
|
137 | */ |
|
|
138 | if (have) |
|
|
139 | return 1; |
|
|
140 | } |
|
|
141 | } |
|
|
142 | else |
145 | } else { |
143 | { |
146 | // space does not block the ob, directly, but |
144 | /* Broke apart a big nasty if into several here to make |
147 | // anything alive that is not a door still |
145 | * this more readable. first check - if the space blocks |
148 | // blocks anything but wizards. |
146 | * movement, can't move here. |
|
|
147 | * second - if a monster, can't move there, unless it is a |
|
|
148 | * dm. |
|
|
149 | */ |
|
|
150 | if (OB_MOVE_BLOCK (ob, tmp)) |
|
|
151 | return 1; |
|
|
152 | |
149 | |
153 | if (tmp->flag [FLAG_ALIVE] |
150 | if (tmp->flag [FLAG_ALIVE] |
154 | && tmp->head_ () != ob |
151 | && tmp->head_ () != ob |
155 | && tmp != ob |
152 | && tmp != ob |
156 | && tmp->type != DOOR |
153 | && tmp->type != DOOR |
157 | && !tmp->flag [FLAG_WIZ]) |
154 | && !tmp->flag [FLAG_WIZPASS]) |
158 | return 1; |
155 | return 1; |
159 | } |
156 | } |
160 | } |
157 | } |
161 | |
158 | |
162 | return 0; |
159 | return 0; |
… | |
… | |
560 | return items; |
557 | return items; |
561 | } |
558 | } |
562 | |
559 | |
563 | /* opposite of parse string, this puts the string that was originally fed in to |
560 | /* opposite of parse string, this puts the string that was originally fed in to |
564 | * the map (or something equivilent) into output_string. */ |
561 | * the map (or something equivilent) into output_string. */ |
565 | static void |
562 | static const char * |
566 | print_shop_string (maptile *m, char *output_string) |
563 | print_shop_string (maptile *m) |
567 | { |
564 | { |
568 | int i; |
565 | static dynbuf_text buf; buf.clear (); |
569 | char tmp[MAX_BUF]; |
|
|
570 | |
566 | |
571 | strcpy (output_string, ""); |
|
|
572 | for (i = 0; i < m->shopitems[0].index; i++) |
567 | for (int i = 0; i < m->shopitems[0].index; i++) |
573 | { |
568 | { |
574 | if (m->shopitems[i].typenum) |
569 | if (m->shopitems[i].typenum) |
575 | { |
570 | { |
576 | if (m->shopitems[i].strength) |
571 | if (m->shopitems[i].strength) |
577 | sprintf (tmp, "%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); |
572 | buf.printf ("%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); |
578 | else |
573 | else |
579 | sprintf (tmp, "%s;", m->shopitems[i].name); |
574 | buf.printf ("%s;", m->shopitems[i].name); |
580 | } |
575 | } |
581 | else |
576 | else |
582 | { |
577 | { |
583 | if (m->shopitems[i].strength) |
578 | if (m->shopitems[i].strength) |
584 | sprintf (tmp, "*:%d;", m->shopitems[i].strength); |
579 | buf.printf ("*:%d;", m->shopitems[i].strength); |
585 | else |
580 | else |
586 | sprintf (tmp, "*"); |
581 | buf.printf ("*"); |
587 | } |
582 | } |
588 | |
|
|
589 | strcat (output_string, tmp); |
|
|
590 | } |
583 | } |
|
|
584 | |
|
|
585 | return buf; |
591 | } |
586 | } |
592 | |
587 | |
593 | /* This loads the header information of the map. The header |
588 | /* This loads the header information of the map. The header |
594 | * contains things like difficulty, size, timeout, etc. |
589 | * contains things like difficulty, size, timeout, etc. |
595 | * this used to be stored in the map object, but with the |
590 | * this used to be stored in the map object, but with the |
… | |
… | |
730 | MAP_OUT (reset_timeout); |
725 | MAP_OUT (reset_timeout); |
731 | MAP_OUT (fixed_resettime); |
726 | MAP_OUT (fixed_resettime); |
732 | MAP_OUT (no_reset); |
727 | MAP_OUT (no_reset); |
733 | MAP_OUT (no_drop); |
728 | MAP_OUT (no_drop); |
734 | MAP_OUT (difficulty); |
729 | MAP_OUT (difficulty); |
735 | |
|
|
736 | if (default_region) MAP_OUT2 (region, default_region->name); |
730 | if (default_region) MAP_OUT2 (region, default_region->name); |
737 | |
731 | |
738 | if (shopitems) |
732 | if (shopitems) MAP_OUT2 (shopitems, print_shop_string (this)); |
739 | { |
|
|
740 | char shop[MAX_BUF]; |
|
|
741 | print_shop_string (this, shop); |
|
|
742 | MAP_OUT2 (shopitems, shop); |
|
|
743 | } |
|
|
744 | |
|
|
745 | MAP_OUT (shopgreed); |
733 | MAP_OUT (shopgreed); |
746 | MAP_OUT (shopmin); |
734 | MAP_OUT (shopmin); |
747 | MAP_OUT (shopmax); |
735 | MAP_OUT (shopmax); |
748 | if (shoprace) MAP_OUT (shoprace); |
736 | if (shoprace) MAP_OUT (shoprace); |
|
|
737 | |
749 | MAP_OUT (darkness); |
738 | MAP_OUT (darkness); |
750 | MAP_OUT (width); |
739 | MAP_OUT (width); |
751 | MAP_OUT (height); |
740 | MAP_OUT (height); |
752 | MAP_OUT (enter_x); |
741 | MAP_OUT (enter_x); |
753 | MAP_OUT (enter_y); |
742 | MAP_OUT (enter_y); |