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

Comparing deliantra/server/server/player.C (file contents):
Revision 1.91 by root, Sun Jan 7 23:10:43 2007 UTC vs.
Revision 1.93 by root, Mon Jan 8 14:11:05 2007 UTC

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
188void 190void
189player::deactivate () 191player::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
209 215
210 ns->update_look = 0; 216 ns->update_look = 0;
211 ns->look_position = 0; 217 ns->look_position = 0;
212 218
213 clear_los (ob); 219 clear_los (ob);
220
221//TODO: must move into client
222/* we need to clear these to -1 and not zero - otherwise,
223 * if a player quits and starts a new character, we wont
224 * send new values to the client, as things like exp start
225 * at zero.
226 */
227for (int i = 0; i < NUM_SKILLS; i++)
228 last_skill_exp[i] = -1;
229
230for (int i = 0; i < NROFATTACKS; i++)
231 last_resist[i] = -1;
232
233last_weapon_sp = -1;
234last_level = -1;
235last_stats.exp = -1;
236last_weight = (uint32) - 1;
237last_flags = 0;
238last_weight = 0;
239last_weight_limit = 0;
240last_path_attuned = 0;
241last_path_repelled = 0;
242last_path_denied = 0;
243last_speed = 0;
244run_on = 0;
245fire_on = 0;
246memset (&last_stats, 0, sizeof (living)); //TODO dirty
214 247
215 /* make sure he's a player -- needed because of class change. */ 248 /* make sure he's a player -- needed because of class change. */
216 ob->type = PLAYER; // we are paranoid 249 ob->type = PLAYER; // we are paranoid
217 ob->race = ob->arch->clone.race; 250 ob->race = ob->arch->clone.race;
218 251
251 else if (tmp->arch->name == dragon_skin_force) 284 else if (tmp->arch->name == dragon_skin_force)
252 skin = tmp; 285 skin = tmp;
253 286
254 set_dragon_name (ob, abil, skin); 287 set_dragon_name (ob, abil, skin);
255 } 288 }
256
257 CLEAR_FLAG (ob, FLAG_FRIENDLY);
258 add_friendly_object (ob);
259 289
260 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); 290 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!");
261 291
262 esrv_new_player (this, ob->weight + ob->carrying); 292 esrv_new_player (this, ob->weight + ob->carrying);
263 293
330 listening = 10; 360 listening = 10;
331 usekeys = containers; 361 usekeys = containers;
332 last_weapon_sp = -1; 362 last_weapon_sp = -1;
333 peaceful = 1; /* default peaceful */ 363 peaceful = 1; /* default peaceful */
334 do_los = 1; 364 do_los = 1;
335
336 /* we need to clear these to -1 and not zero - otherwise,
337 * if a player quits and starts a new character, we wont
338 * send new values to the client, as things like exp start
339 * at zero.
340 */
341 for (int i = 0; i < NUM_SKILLS; i++)
342 last_skill_exp[i] = -1;
343
344 for (int i = 0; i < NROFATTACKS; i++)
345 last_resist[i] = -1;
346
347 last_stats.exp = -1;
348 last_weight = (uint32) - 1;
349} 365}
350 366
351void 367void
352player::do_destroy () 368player::do_destroy ()
353{ 369{
417 object *op = NULL; 433 object *op = NULL;
418 objectlink *ol; 434 objectlink *ol;
419 unsigned lastdist; 435 unsigned lastdist;
420 rv_vector rv; 436 rv_vector rv;
421 437
422 for (ol = first_friendly_object, lastdist = 1000; ol != NULL; ol = ol->next) 438 for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next)
423 { 439 {
424 /* We should not find free objects on this friendly list, but it 440 /* We should not find free objects on this friendly list, but it
425 * does periodically happen. Given that, lets deal with it. 441 * does periodically happen. Given that, lets deal with it.
426 * While unlikely, it is possible the next object on the friendly 442 * While unlikely, it is possible the next object on the friendly
427 * list is also free, so encapsulate this in a while loop. 443 * list is also free, so encapsulate this in a while loop.
431 object *tmp = ol->ob; 447 object *tmp = ol->ob;
432 448
433 /* Can't do much more other than log the fact, because the object 449 /* Can't do much more other than log the fact, because the object
434 * itself will have been cleared. 450 * itself will have been cleared.
435 */ 451 */
436 LOG (llevDebug, "get_nearest_player: Found free/non friendly object on friendly list\n"); 452 LOG (llevDebug, "get_nearest_player: Found free/non friendly object '%s' on friendly list\n",
453 tmp->debug_desc ());
437 ol = ol->next; 454 ol = ol->next;
438 remove_friendly_object (tmp); 455 remove_friendly_object (tmp);
439 if (!ol) 456 if (!ol)
440 return op; 457 return op;
441 } 458 }
1859 { 1876 {
1860 if (op->type == PLAYER) 1877 if (op->type == PLAYER)
1861 new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); 1878 new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use.");
1862 return; 1879 return;
1863 } 1880 }
1881
1864 (void) do_skill (op, op, op->chosen_skill, dir, NULL); 1882 do_skill (op, op, op->chosen_skill, dir, NULL);
1865 return; 1883 return;
1866 case range_builder: 1884 case range_builder:
1867 apply_map_builder (op, dir); 1885 apply_map_builder (op, dir);
1868 return; 1886 return;
1869 default: 1887 default:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines