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.92 by root, Mon Jan 8 01:19:04 2007 UTC vs.
Revision 1.99 by root, Thu Jan 18 19:42:10 2007 UTC

194 return; 194 return;
195 195
196 terminate_all_pets (ob); 196 terminate_all_pets (ob);
197 remove_friendly_object (ob); 197 remove_friendly_object (ob);
198 ob->deactivate_recursive (); 198 ob->deactivate_recursive ();
199 maplevel = ob->map->path;
199 ob->remove (); 200 ob->remove ();
200 ob->map = 0; 201 ob->map = 0;
201 202
202 // for weird reasons, this is often "ob", keeping a circular reference 203 // for weird reasons, this is often "ob", keeping a circular reference
203 ranges [range_skill] = 0; 204 ranges [range_skill] = 0;
211player::connect (client *ns) 212player::connect (client *ns)
212{ 213{
213 this->ns = ns; 214 this->ns = ns;
214 ns->pl = this; 215 ns->pl = this;
215 216
217 run_on = 0;
218 fire_on = 0;
219 ob->container = 0; //TODO: client-specific
220
216 ns->update_look = 0; 221 ns->update_look = 0;
217 ns->look_position = 0; 222 ns->look_position = 0;
218 223
219 clear_los (ob); 224 clear_los (ob);
225
226 ns->reset_stats ();
220 227
221 /* make sure he's a player -- needed because of class change. */ 228 /* make sure he's a player -- needed because of class change. */
222 ob->type = PLAYER; // we are paranoid 229 ob->type = PLAYER; // we are paranoid
223 ob->race = ob->arch->clone.race; 230 ob->race = ob->arch->clone.race;
224 231
288 if (active) 295 if (active)
289 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); 296 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0));
290 297
291 INVOKE_PLAYER (DISCONNECT, this); 298 INVOKE_PLAYER (DISCONNECT, this);
292 299
300 ns->reset_stats ();
293 ns->pl = 0; 301 ns->pl = 0;
294 this->ns = 0; 302 this->ns = 0;
295 } 303 }
296 304
305 ob->container = 0; //TODO: client-specific
297 deactivate (); 306 deactivate ();
298} 307}
299 308
300// the need for this function can be explained 309// the need for this function can be explained
301// by load_object not returning the object 310// by load_object not returning the object
324 unapply = unapply_nochoice; 333 unapply = unapply_nochoice;
325 334
326 savebed_map = first_map_path; /* Init. respawn position */ 335 savebed_map = first_map_path; /* Init. respawn position */
327 336
328 gen_sp_armour = 10; 337 gen_sp_armour = 10;
329 last_speed = -1;
330 shoottype = range_none; 338 shoottype = range_none;
331 bowtype = bow_normal; 339 bowtype = bow_normal;
332 petmode = pet_normal; 340 petmode = pet_normal;
333 listening = 10; 341 listening = 10;
334 usekeys = containers; 342 usekeys = containers;
335 last_weapon_sp = -1;
336 peaceful = 1; /* default peaceful */ 343 peaceful = 1; /* default peaceful */
337 do_los = 1; 344 do_los = 1;
338
339 /* we need to clear these to -1 and not zero - otherwise,
340 * if a player quits and starts a new character, we wont
341 * send new values to the client, as things like exp start
342 * at zero.
343 */
344 for (int i = 0; i < NUM_SKILLS; i++)
345 last_skill_exp[i] = -1;
346
347 for (int i = 0; i < NROFATTACKS; i++)
348 last_resist[i] = -1;
349
350 last_stats.exp = -1;
351 last_weight = (uint32) - 1;
352} 345}
353 346
354void 347void
355player::do_destroy () 348player::do_destroy ()
356{ 349{
763roll_stat (void) 756roll_stat (void)
764{ 757{
765 int a[4], i, j, k; 758 int a[4], i, j, k;
766 759
767 for (i = 0; i < 4; i++) 760 for (i = 0; i < 4; i++)
768 a[i] = (int) RANDOM () % 6 + 1; 761 a[i] = (int) rndm (6) + 1;
769 762
770 for (i = 0, j = 0, k = 7; i < 4; i++) 763 for (i = 0, j = 0, k = 7; i < 4; i++)
771 if (a[i] < k) 764 if (a[i] < k)
772 k = a[i], j = i; 765 k = a[i], j = i;
773 766
903 * to save here. 896 * to save here.
904 */ 897 */
905 sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name); 898 sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name);
906 make_path_to_file (buf); 899 make_path_to_file (buf);
907 900
908#ifdef AUTOSAVE
909 op->contr->last_save_tick = pticks;
910#endif
911 start_info (op); 901 start_info (op);
912 CLEAR_FLAG (op, FLAG_WIZ); 902 CLEAR_FLAG (op, FLAG_WIZ);
913 give_initial_items (op, op->randomitems); 903 give_initial_items (op, op->randomitems);
914 link_player_skills (op); 904 link_player_skills (op);
915 esrv_send_inventory (op, op); 905 esrv_send_inventory (op, op);
2221 return 0; 2211 return 0;
2222 } 2212 }
2223 2213
2224 /* peterm: added following line */ 2214 /* peterm: added following line */
2225 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2215 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2226 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 2216 dir = absdir (dir + rndm (3) + rndm (3) - 2);
2227 2217
2228 op->facing = dir; 2218 op->facing = dir;
2229 2219
2230 if (op->hide) 2220 if (op->hide)
2231 do_hidden_move (op); 2221 do_hidden_move (op);
2992 tmp->x = op->x, tmp->y = op->y; 2982 tmp->x = op->x, tmp->y = op->y;
2993 if (tmp->type == CONTAINER) 2983 if (tmp->type == CONTAINER)
2994 { /* empty container to ground */ 2984 { /* empty container to ground */
2995 loot_object (tmp); 2985 loot_object (tmp);
2996 } 2986 }
2997 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 2987 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3))))
2998 { 2988 {
2999 if (tmp->nrof > 1) 2989 if (tmp->nrof > 1)
3000 { 2990 {
3001 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 2991 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3002 tmp2->destroy (); 2992 tmp2->destroy ();
3536 * not readied. 3526 * not readied.
3537 */ 3527 */
3538void 3528void
3539player_unready_range_ob (player *pl, object *ob) 3529player_unready_range_ob (player *pl, object *ob)
3540{ 3530{
3541 rangetype i;
3542
3543 for (i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1)) 3531 for (rangetype i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1))
3544 {
3545 if (pl->ranges[i] == ob) 3532 if (pl->ranges[i] == ob)
3546 { 3533 {
3547 pl->ranges[i] = NULL; 3534 pl->ranges[i] = 0;
3548 if (pl->shoottype == i) 3535 if (pl->shoottype == i)
3549 {
3550 pl->shoottype = range_none; 3536 pl->shoottype = range_none;
3551 }
3552 } 3537 }
3553 }
3554} 3538}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines