… | |
… | |
180 | |
180 | |
181 | players.insert (this); |
181 | players.insert (this); |
182 | ob->remove (); |
182 | ob->remove (); |
183 | ob->map = 0; |
183 | ob->map = 0; |
184 | ob->activate_recursive (); |
184 | ob->activate_recursive (); |
|
|
185 | CLEAR_FLAG (ob, FLAG_FRIENDLY); |
|
|
186 | add_friendly_object (ob); |
185 | enter_map (); |
187 | enter_map (); |
186 | } |
188 | } |
187 | |
189 | |
188 | void |
190 | void |
189 | player::deactivate () |
191 | player::deactivate () |
190 | { |
192 | { |
191 | if (!active) |
193 | if (!active) |
192 | return; |
194 | return; |
193 | |
195 | |
194 | terminate_all_pets (ob); |
196 | terminate_all_pets (ob); |
|
|
197 | remove_friendly_object (ob); |
195 | ob->deactivate_recursive (); |
198 | ob->deactivate_recursive (); |
196 | ob->remove (); |
199 | ob->remove (); |
197 | ob->map = 0; |
200 | ob->map = 0; |
|
|
201 | |
|
|
202 | // for weird reasons, this is often "ob", keeping a circular reference |
|
|
203 | ranges [range_skill] = 0; |
198 | |
204 | |
199 | players.erase (this); |
205 | players.erase (this); |
200 | } |
206 | } |
201 | |
207 | |
202 | // connect the player with a specific client |
208 | // connect the player with a specific client |
… | |
… | |
251 | else if (tmp->arch->name == dragon_skin_force) |
257 | else if (tmp->arch->name == dragon_skin_force) |
252 | skin = tmp; |
258 | skin = tmp; |
253 | |
259 | |
254 | set_dragon_name (ob, abil, skin); |
260 | set_dragon_name (ob, abil, skin); |
255 | } |
261 | } |
256 | |
|
|
257 | CLEAR_FLAG (ob, FLAG_FRIENDLY); |
|
|
258 | add_friendly_object (ob); |
|
|
259 | |
262 | |
260 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
263 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
261 | |
264 | |
262 | esrv_new_player (this, ob->weight + ob->carrying); |
265 | esrv_new_player (this, ob->weight + ob->carrying); |
263 | |
266 | |
… | |
… | |
417 | object *op = NULL; |
420 | object *op = NULL; |
418 | objectlink *ol; |
421 | objectlink *ol; |
419 | unsigned lastdist; |
422 | unsigned lastdist; |
420 | rv_vector rv; |
423 | rv_vector rv; |
421 | |
424 | |
422 | for (ol = first_friendly_object, lastdist = 1000; ol != NULL; ol = ol->next) |
425 | for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next) |
423 | { |
426 | { |
424 | /* We should not find free objects on this friendly list, but it |
427 | /* We should not find free objects on this friendly list, but it |
425 | * does periodically happen. Given that, lets deal with it. |
428 | * does periodically happen. Given that, lets deal with it. |
426 | * While unlikely, it is possible the next object on the friendly |
429 | * While unlikely, it is possible the next object on the friendly |
427 | * list is also free, so encapsulate this in a while loop. |
430 | * list is also free, so encapsulate this in a while loop. |
… | |
… | |
431 | object *tmp = ol->ob; |
434 | object *tmp = ol->ob; |
432 | |
435 | |
433 | /* Can't do much more other than log the fact, because the object |
436 | /* Can't do much more other than log the fact, because the object |
434 | * itself will have been cleared. |
437 | * itself will have been cleared. |
435 | */ |
438 | */ |
436 | LOG (llevDebug, "get_nearest_player: Found free/non friendly object on friendly list\n"); |
439 | LOG (llevDebug, "get_nearest_player: Found free/non friendly object '%s' on friendly list\n", |
|
|
440 | tmp->debug_desc ()); |
437 | ol = ol->next; |
441 | ol = ol->next; |
438 | remove_friendly_object (tmp); |
442 | remove_friendly_object (tmp); |
439 | if (!ol) |
443 | if (!ol) |
440 | return op; |
444 | return op; |
441 | } |
445 | } |
… | |
… | |
1859 | { |
1863 | { |
1860 | if (op->type == PLAYER) |
1864 | if (op->type == PLAYER) |
1861 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
1865 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
1862 | return; |
1866 | return; |
1863 | } |
1867 | } |
|
|
1868 | |
1864 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
1869 | do_skill (op, op, op->chosen_skill, dir, NULL); |
1865 | return; |
1870 | return; |
1866 | case range_builder: |
1871 | case range_builder: |
1867 | apply_map_builder (op, dir); |
1872 | apply_map_builder (op, dir); |
1868 | return; |
1873 | return; |
1869 | default: |
1874 | default: |