… | |
… | |
81 | |
81 | |
82 | if (contr && map != newmap && map) |
82 | if (contr && map != newmap && map) |
83 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
83 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
84 | return; |
84 | return; |
85 | |
85 | |
86 | // remove, so stupid ob_locked does not trigger a failure |
86 | // remove, so stupid blocked does not trigger a failure |
87 | remove (); |
87 | remove (); |
88 | |
88 | |
89 | /* try to find a spot for the player */ |
89 | /* try to find a spot for the player */ |
90 | if (blocked (newmap, x, y)) |
90 | if (blocked (newmap, x, y)) |
91 | { /* First choice blocked */ |
91 | { /* First choice blocked */ |
… | |
… | |
96 | * Note that for the second and third calls, we could start at a position other |
96 | * Note that for the second and third calls, we could start at a position other |
97 | * than one, but then we could end up on the other side of walls and so forth. |
97 | * than one, but then we could end up on the other side of walls and so forth. |
98 | */ |
98 | */ |
99 | int i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE1 + 1); |
99 | int i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE1 + 1); |
100 | |
100 | |
101 | if (i == -1) |
101 | if (i < 0) |
102 | { |
102 | { |
103 | i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE2 + 1); |
103 | i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE2 + 1); |
104 | if (i == -1) |
104 | if (i < 0) |
105 | i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE); |
105 | i = find_free_spot (this, newmap, x, y, 1, SIZEOFFREE); |
106 | } |
106 | } |
107 | |
107 | |
108 | if (i != -1) |
108 | if (i >= 0) |
109 | { |
109 | { |
110 | x += freearr_x[i]; |
110 | x += freearr_x[i]; |
111 | y += freearr_y[i]; |
111 | y += freearr_y[i]; |
112 | } |
112 | } |
113 | else |
113 | else |
… | |
… | |
122 | |
122 | |
123 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (contr), ARG_INT (x), ARG_INT (y))) |
123 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (contr), ARG_INT (x), ARG_INT (y))) |
124 | return; |
124 | return; |
125 | } |
125 | } |
126 | |
126 | |
127 | this->x = x; |
|
|
128 | this->y = y; |
|
|
129 | map = newmap; |
|
|
130 | |
|
|
131 | insert_ob_in_map (this, map, 0, INS_NO_WALK_ON); |
|
|
132 | |
|
|
133 | enemy = 0; |
127 | enemy = 0; |
134 | |
128 | |
|
|
129 | newmap->insert (this, x, y, 0, INS_NO_WALK_ON); |
|
|
130 | |
|
|
131 | if (map == newmap) |
|
|
132 | { |
135 | if (contr) |
133 | if (contr) |
136 | { |
134 | { |
137 | contr->maplevel = newmap->path; |
135 | contr->maplevel = newmap->path; |
138 | contr->count = 0; |
136 | contr->count = 0; |
139 | } |
|
|
140 | |
137 | |
141 | /* Update any golems */ |
138 | /* Update any golems */ |
142 | if (type == PLAYER) |
|
|
143 | if (object *golem = contr->golem) |
139 | if (object *golem = contr->golem) |
144 | { |
140 | { |
145 | int i = find_free_spot (golem, newmap, x, y, 1, SIZEOFFREE); |
141 | int i = find_free_spot (golem, newmap, x, y, 1, SIZEOFFREE); |
146 | |
142 | |
147 | if (i < 0) |
143 | if (i < 0) |
148 | golem->drop_and_destroy (); |
144 | golem->drop_and_destroy (); |
149 | else |
145 | else |
150 | { |
146 | { |
151 | newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]); |
147 | newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]); |
152 | golem->direction = find_dir_2 (golem->x - x, golem->y - y); |
148 | golem->direction = find_dir_2 (golem->x - x, golem->y - y); |
|
|
149 | } |
153 | } |
150 | } |
154 | } |
151 | } |
155 | |
152 | |
156 | /* since the players map is already loaded, we don't need to worry |
153 | /* since the players map is already loaded, we don't need to worry |
157 | * about pending objects. |
154 | * about pending objects. |
158 | */ |
155 | */ |
159 | remove_all_pets (newmap); |
156 | move_all_pets (); |
|
|
157 | } |
160 | } |
158 | } |
161 | |
159 | |
162 | /* process_players1 and process_players2 do all the player related stuff. |
160 | /* process_players1 and process_players2 do all the player related stuff. |
163 | * I moved it out of process events and process_map. This was to some |
161 | * I moved it out of process events and process_map. This was to some |
164 | * extent for debugging as well as to get a better idea of the time used |
162 | * extent for debugging as well as to get a better idea of the time used |