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.94 by root, Mon Jan 8 14:29: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
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 289
257 CLEAR_FLAG (ob, FLAG_FRIENDLY);
258 add_friendly_object (ob);
259
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
264 ob->update_stats (); 294 ob->update_stats ();
321 unapply = unapply_nochoice; 351 unapply = unapply_nochoice;
322 352
323 savebed_map = first_map_path; /* Init. respawn position */ 353 savebed_map = first_map_path; /* Init. respawn position */
324 354
325 gen_sp_armour = 10; 355 gen_sp_armour = 10;
326 last_speed = -1;
327 shoottype = range_none; 356 shoottype = range_none;
328 bowtype = bow_normal; 357 bowtype = bow_normal;
329 petmode = pet_normal; 358 petmode = pet_normal;
330 listening = 10; 359 listening = 10;
331 usekeys = containers; 360 usekeys = containers;
332 last_weapon_sp = -1;
333 peaceful = 1; /* default peaceful */ 361 peaceful = 1; /* default peaceful */
334 do_los = 1; 362 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} 363}
350 364
351void 365void
352player::do_destroy () 366player::do_destroy ()
353{ 367{
417 object *op = NULL; 431 object *op = NULL;
418 objectlink *ol; 432 objectlink *ol;
419 unsigned lastdist; 433 unsigned lastdist;
420 rv_vector rv; 434 rv_vector rv;
421 435
422 for (ol = first_friendly_object, lastdist = 1000; ol != NULL; ol = ol->next) 436 for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next)
423 { 437 {
424 /* We should not find free objects on this friendly list, but it 438 /* We should not find free objects on this friendly list, but it
425 * does periodically happen. Given that, lets deal with it. 439 * does periodically happen. Given that, lets deal with it.
426 * While unlikely, it is possible the next object on the friendly 440 * While unlikely, it is possible the next object on the friendly
427 * list is also free, so encapsulate this in a while loop. 441 * list is also free, so encapsulate this in a while loop.
431 object *tmp = ol->ob; 445 object *tmp = ol->ob;
432 446
433 /* Can't do much more other than log the fact, because the object 447 /* Can't do much more other than log the fact, because the object
434 * itself will have been cleared. 448 * itself will have been cleared.
435 */ 449 */
436 LOG (llevDebug, "get_nearest_player: Found free/non friendly object on friendly list\n"); 450 LOG (llevDebug, "get_nearest_player: Found free/non friendly object '%s' on friendly list\n",
451 tmp->debug_desc ());
437 ol = ol->next; 452 ol = ol->next;
438 remove_friendly_object (tmp); 453 remove_friendly_object (tmp);
439 if (!ol) 454 if (!ol)
440 return op; 455 return op;
441 } 456 }
1859 { 1874 {
1860 if (op->type == PLAYER) 1875 if (op->type == PLAYER)
1861 new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); 1876 new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use.");
1862 return; 1877 return;
1863 } 1878 }
1879
1864 (void) do_skill (op, op, op->chosen_skill, dir, NULL); 1880 do_skill (op, op, op->chosen_skill, dir, NULL);
1865 return; 1881 return;
1866 case range_builder: 1882 case range_builder:
1867 apply_map_builder (op, dir); 1883 apply_map_builder (op, dir);
1868 return; 1884 return;
1869 default: 1885 default:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines