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.96 by root, Mon Jan 8 19:25:53 2007 UTC vs.
Revision 1.100 by root, Sat Jan 20 22:09:55 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;
213 this->ns = ns; 214 this->ns = ns;
214 ns->pl = this; 215 ns->pl = this;
215 216
216 run_on = 0; 217 run_on = 0;
217 fire_on = 0; 218 fire_on = 0;
219 ob->container = 0; //TODO: client-specific
218 220
219 ns->update_look = 0; 221 ns->update_look = 0;
220 ns->look_position = 0; 222 ns->look_position = 0;
221 223
222 clear_los (ob); 224 clear_los (ob);
293 if (active) 295 if (active)
294 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); 296 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0));
295 297
296 INVOKE_PLAYER (DISCONNECT, this); 298 INVOKE_PLAYER (DISCONNECT, this);
297 299
300 ns->reset_stats ();
298 ns->pl = 0; 301 ns->pl = 0;
299 this->ns = 0; 302 this->ns = 0;
300 } 303 }
301 304
305 ob->container = 0; //TODO: client-specific
302 deactivate (); 306 deactivate ();
303} 307}
304 308
305// the need for this function can be explained 309// the need for this function can be explained
306// by load_object not returning the object 310// by load_object not returning the object
523 x = mon->x; 527 x = mon->x;
524 y = mon->y; 528 y = mon->y;
525 m = mon->map; 529 m = mon->map;
526 dir = rv.direction; 530 dir = rv.direction;
527 lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ 531 lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */
528 diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); 532 diff = ::max (abs (rv.distance_x), abs (rv.distance_y));
533
529 /* If we can't solve it within the search distance, return now. */ 534 /* If we can't solve it within the search distance, return now. */
530 if (diff > max) 535 if (diff > max)
531 return 0; 536 return 0;
537
532 while (diff > 1 && max > 0) 538 while (diff > 1 && max > 0)
533 { 539 {
534 lastx = x; 540 lastx = x;
535 lasty = y; 541 lasty = y;
536 lastmap = m; 542 lastmap = m;
618 max--; 624 max--;
619 lastdir = dir; 625 lastdir = dir;
620 if (!firstdir) 626 if (!firstdir)
621 firstdir = dir; 627 firstdir = dir;
622 } 628 }
629
623 if (diff <= 1) 630 if (diff <= 1)
624 { 631 {
625 /* Recalculate diff (distance) because we may not have actually 632 /* Recalculate diff (distance) because we may not have actually
626 * headed toward player for entire distance. 633 * headed toward player for entire distance.
627 */ 634 */
628 get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); 635 get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0);
629 diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); 636 diff = ::max (abs (rv.distance_x), abs (rv.distance_y));
630 } 637 }
638
631 if (diff > max) 639 if (diff > max)
632 return 0; 640 return 0;
633 } 641 }
642
634 /* If we reached the max, didn't find a direction in time */ 643 /* If we reached the max, didn't find a direction in time */
635 if (!max) 644 if (!max)
636 return 0; 645 return 0;
637 646
638 return firstdir; 647 return firstdir;
752roll_stat (void) 761roll_stat (void)
753{ 762{
754 int a[4], i, j, k; 763 int a[4], i, j, k;
755 764
756 for (i = 0; i < 4; i++) 765 for (i = 0; i < 4; i++)
757 a[i] = (int) RANDOM () % 6 + 1; 766 a[i] = (int) rndm (6) + 1;
758 767
759 for (i = 0, j = 0, k = 7; i < 4; i++) 768 for (i = 0, j = 0, k = 7; i < 4; i++)
760 if (a[i] < k) 769 if (a[i] < k)
761 k = a[i], j = i; 770 k = a[i], j = i;
762 771
2207 return 0; 2216 return 0;
2208 } 2217 }
2209 2218
2210 /* peterm: added following line */ 2219 /* peterm: added following line */
2211 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2220 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2212 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 2221 dir = absdir (dir + rndm (3) + rndm (3) - 2);
2213 2222
2214 op->facing = dir; 2223 op->facing = dir;
2215 2224
2216 if (op->hide) 2225 if (op->hide)
2217 do_hidden_move (op); 2226 do_hidden_move (op);
2978 tmp->x = op->x, tmp->y = op->y; 2987 tmp->x = op->x, tmp->y = op->y;
2979 if (tmp->type == CONTAINER) 2988 if (tmp->type == CONTAINER)
2980 { /* empty container to ground */ 2989 { /* empty container to ground */
2981 loot_object (tmp); 2990 loot_object (tmp);
2982 } 2991 }
2983 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 2992 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3))))
2984 { 2993 {
2985 if (tmp->nrof > 1) 2994 if (tmp->nrof > 1)
2986 { 2995 {
2987 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 2996 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
2988 tmp2->destroy (); 2997 tmp2->destroy ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines