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

Comparing deliantra/server/server/time.C (file contents):
Revision 1.108 by root, Thu Apr 15 02:10:26 2010 UTC vs.
Revision 1.118 by root, Fri Jan 27 22:00:40 2012 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
239{ /* 1 = going down, 0 = going up */ 239{ /* 1 = going down, 0 = going up */
240 object *tmp; 240 object *tmp;
241 241
242 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) 242 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op))
243 { 243 {
244 LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op)); 244 LOG (llevError, "%s: gate error: animation was %d, max=%d\n", op->debug_desc (), op->stats.wc, NUM_ANIMATIONS (op));
245 op->stats.wc = 0; 245 op->stats.wc = 0;
246 } 246 }
247 247
248 /* We're going down */ 248 /* We're going down */
249 if (op->value) 249 if (op->value)
272 /* We're going up */ 272 /* We're going up */
273 273
274 /* First, lets see if we are already at the top */ 274 /* First, lets see if we are already at the top */
275 if ((unsigned char) op->stats.wc == (NUM_ANIMATIONS (op) - 1)) 275 if ((unsigned char) op->stats.wc == (NUM_ANIMATIONS (op) - 1))
276 { 276 {
277
278 /* Check to make sure that only non pickable and non rollable 277 /* Check to make sure that only non pickable and non rollable
279 * objects are above the gate. If so, we finish closing the gate, 278 * objects are above the gate. If so, we finish closing the gate,
280 * otherwise, we fall through to the code below which should lower 279 * otherwise, we fall through to the code below which should lower
281 * the gate slightly. 280 * the gate slightly.
282 */ 281 */
502 move_apply (op, tmp, tmp); 501 move_apply (op, tmp, tmp);
503 } 502 }
504 } 503 }
505 504
506 SET_ANIMATION (op, op->stats.wc); 505 SET_ANIMATION (op, op->stats.wc);
507 update_object (op, UP_OBJ_FACE); 506 update_object (op, UP_OBJ_CHANGE);
508 return; 507 return;
509 } 508 }
510 509
511 /* We're closing */ 510 /* We're closing */
512 op->move_on = 0; 511 op->move_on = 0;
513 512
514 op->stats.wc++; 513 op->stats.wc++;
515 if ((int) op->stats.wc >= NUM_ANIMATIONS (op)) 514 if (op->stats.wc >= NUM_ANIMATIONS (op))
516 op->stats.wc = NUM_ANIMATIONS (op) - 1; 515 op->stats.wc = NUM_ANIMATIONS (op) - 1;
517 516
518 SET_ANIMATION (op, op->stats.wc); 517 SET_ANIMATION (op, op->stats.wc);
519 update_object (op, UP_OBJ_FACE); 518 update_object (op, UP_OBJ_CHANGE);
520 if ((unsigned char) op->stats.wc == (NUM_ANIMATIONS (op) - 1)) 519 if (op->stats.wc == (NUM_ANIMATIONS (op) - 1))
521 op->set_speed (0); /* closed, let's stop */ 520 op->set_speed (0); /* closed, let's stop */
522} 521}
523 522
524 523
525/* stop_item() returns a pointer to the stopped object. The stopped object 524/* stop_item() returns a pointer to the stopped object. The stopped object
655{ 654{
656 int was_reflected; 655 int was_reflected;
657 656
658 if (!op->map) 657 if (!op->map)
659 { 658 {
660 LOG (llevError, "BUG: Arrow had no map.\n"); 659 LOG (llevError | logBacktrace, "BUG: Arrow %s had no map.\n", op->debug_desc ());
661 op->destroy (); 660 op->destroy ();
662 return; 661 return;
663 } 662 }
664 663
665 /* we need to stop thrown objects at some point. Like here. */ 664 /* we need to stop thrown objects at some point. Like here. */
687 } 686 }
688 687
689 /* decrease the speed as it flies. 0.05 means a standard bow will shoot 688 /* decrease the speed as it flies. 0.05 means a standard bow will shoot
690 * about 17 squares. Tune as needed. 689 * about 17 squares. Tune as needed.
691 */ 690 */
692 op->speed -= 0.05; 691 op->set_speed (op->speed - 0.05);
693 692
694 /* if the arrow is moving too slow.. stop it. 0.5 was chosen as lower 693 /* if the arrow is moving too slow.. stop it. 0.5 was chosen as lower
695 values look rediculous. */ 694 values look rediculous. */
696 if (op->speed < (op->type == ARROW ? 0.05 : MIN_ACTIVE_SPEED)) 695 if (op->speed < (op->type == ARROW ? 0.5 : MIN_ACTIVE_SPEED))
697 { 696 {
698 stop_arrow (op); 697 stop_arrow (op);
699 return; 698 return;
700 } 699 }
701 700
729 * as below. (Note that for living creatures there is a small 728 * as below. (Note that for living creatures there is a small
730 * chance that reflect_missile fails.) 729 * chance that reflect_missile fails.)
731 */ 730 */
732 if (tmp->flag [FLAG_REFL_MISSILE] && (rndm (0, 99)) < (90 - op->level / 10)) 731 if (tmp->flag [FLAG_REFL_MISSILE] && (rndm (0, 99)) < (90 - op->level / 10))
733 { 732 {
734 int number = op->face;
735
736 op->direction = absdir (op->direction + 4); 733 op->direction = absdir (op->direction + 4);
737 update_turn_face (op); 734 update_turn_face (op);
738 was_reflected = 1; /* skip normal movement calculations */ 735 was_reflected = 1; /* skip normal movement calculations */
739 } 736 }
740 else 737 else
1164 int i; 1161 int i;
1165 object *ob_to_copy; 1162 object *ob_to_copy;
1166 1163
1167 /* select random object from inventory to copy */ 1164 /* select random object from inventory to copy */
1168 ob_to_copy = creator->inv; 1165 ob_to_copy = creator->inv;
1169 for (ob = creator->inv->below, i = 1; ob != NULL; ob = ob->below, i++) 1166 for (ob = creator->inv->below, i = 1; ob; ob = ob->below, i++)
1170 { 1167 {
1171 if (rndm (0, i) == 0) 1168 if (rndm (0, i) == 0)
1172 { 1169 {
1173 ob_to_copy = ob; 1170 ob_to_copy = ob;
1174 } 1171 }
1175 } 1172 }
1173
1176 new_ob = ob_to_copy->deep_clone (); 1174 new_ob = ob_to_copy->deep_clone ();
1177 new_ob->clr_flag (FLAG_IS_A_TEMPLATE); 1175 new_ob->clr_flag (FLAG_IS_A_TEMPLATE);
1178 unflag_inv (new_ob, FLAG_IS_A_TEMPLATE); 1176 unflag_inv (new_ob, FLAG_IS_A_TEMPLATE);
1179 } 1177 }
1180 else 1178 else
1197 return; 1195 return;
1198 } 1196 }
1199 1197
1200 // for now lets try to identify everything generated here, it mostly 1198 // for now lets try to identify everything generated here, it mostly
1201 // happens automated, so this will at least fix many identify-experience holes 1199 // happens automated, so this will at least fix many identify-experience holes
1200 if (new_ob->need_identify ())
1202 new_ob->set_flag (FLAG_IDENTIFIED); 1201 new_ob->set_flag (FLAG_IDENTIFIED);
1203 1202
1204 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); 1203 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y);
1205 if (new_ob->flag [FLAG_FREED]) 1204 if (new_ob->flag [FLAG_FREED])
1206 return; 1205 return;
1207 1206
1482 1481
1483 case LAMP: 1482 case LAMP:
1484 case TORCH: 1483 case TORCH:
1485 move_lamp (op); 1484 move_lamp (op);
1486 break; 1485 break;
1487 }
1488}
1489 1486
1487 case PHYSICS: // hmm, bad naming
1488 move_physics (op);
1489 break;
1490 }
1491}
1492

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines