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

Comparing deliantra/server/common/button.C (file contents):
Revision 1.19 by root, Mon Dec 25 11:25:49 2006 UTC vs.
Revision 1.21 by root, Sat Dec 30 10:16:10 2006 UTC

67 switch (tmp->type) 67 switch (tmp->type)
68 { 68 {
69 case GATE: 69 case GATE:
70 case HOLE: 70 case HOLE:
71 tmp->value = tmp->stats.maxsp ? !state : state; 71 tmp->value = tmp->stats.maxsp ? !state : state;
72 tmp->speed = 0.5; 72 tmp->set_speed (0.5);
73 update_ob_speed (tmp);
74 break; 73 break;
75 74
76 case CF_HANDLE: 75 case CF_HANDLE:
77 SET_ANIMATION (tmp, (tmp->value = tmp->stats.maxsp ? !state : state)); 76 SET_ANIMATION (tmp, (tmp->value = tmp->stats.maxsp ? !state : state));
78 update_object (tmp, UP_OBJ_FACE); 77 update_object (tmp, UP_OBJ_FACE);
103 case MOOD_FLOOR: 102 case MOOD_FLOOR:
104 do_mood_floor (tmp, source); 103 do_mood_floor (tmp, source);
105 break; 104 break;
106 105
107 case TIMED_GATE: 106 case TIMED_GATE:
108 tmp->speed = tmp->arch->clone.speed; 107 tmp->set_speed (tmp->arch->clone.speed);
109 update_ob_speed (tmp); /* original values */
110 tmp->value = tmp->arch->clone.value; 108 tmp->value = tmp->arch->clone.value;
111 tmp->stats.sp = 1; 109 tmp->stats.sp = 1;
112 tmp->stats.hp = tmp->stats.maxhp; 110 tmp->stats.hp = tmp->stats.maxhp;
113 /* Handle multipart gates. We copy the value for the other parts 111 /* Handle multipart gates. We copy the value for the other parts
114 * from the head - this ensures that the data will consistent 112 * from the head - this ensures that the data will consistent
115 */ 113 */
116 for (tmp = tmp->more; tmp != NULL; tmp = tmp->more) 114 for (tmp = tmp->more; tmp; tmp = tmp->more)
117 { 115 {
118 tmp->speed = tmp->head->speed;
119 tmp->value = tmp->head->value; 116 tmp->value = tmp->head->value;
120 tmp->stats.sp = tmp->head->stats.sp; 117 tmp->stats.sp = tmp->head->stats.sp;
121 tmp->stats.hp = tmp->head->stats.hp; 118 tmp->stats.hp = tmp->head->stats.hp;
122 update_ob_speed (tmp); 119 tmp->set_speed (tmp->head->speed);
123 } 120 }
124 break; 121 break;
125 122
126 case DIRECTOR: 123 case DIRECTOR:
127 case FIREWALL: 124 case FIREWALL:
276 update_object (op, UP_OBJ_FACE); 273 update_object (op, UP_OBJ_FACE);
277 push_button (op); /* Make all other buttons the same */ 274 push_button (op); /* Make all other buttons the same */
278 } 275 }
279} 276}
280 277
281/*
282 * Updates every button on the map (by calling update_button() for them).
283 */
284
285void
286update_buttons (maptile *m)
287{
288 objectlink *ol;
289 oblinkpt *obp;
290
291 for (obp = m->buttons; obp; obp = obp->next)
292 for (ol = obp->link; ol; ol = ol->next)
293 {
294 if (!ol->ob)
295 {
296 LOG (llevError, "Internal error in update_button (%s (%dx%d), connected %ld).\n",
297 ol->ob ? (const char *) ol->ob->name : "null", ol->ob ? ol->ob->x : -1, ol->ob ? ol->ob->y : -1, obp->value);
298 continue;
299 }
300
301 if (ol->ob->type == BUTTON || ol->ob->type == PEDESTAL)
302 {
303 update_button (ol->ob);
304 break;
305 }
306 }
307}
308
309void 278void
310use_trigger (object *op) 279use_trigger (object *op)
311{ 280{
312
313 /* Toggle value */ 281 /* Toggle value */
314 op->value = !op->value; 282 op->value = !op->value;
315 push_button (op); 283 push_button (op);
316} 284}
317 285
318/* 286/*
319 * Note: animate_object should be used instead of this, 287 * Note: animate_object should be used instead of this,
320 * but it can't handle animations in the 8 directions 288 * but it can't handle animations in the 8 directions
321 */ 289 */
322
323void 290void
324animate_turning (object *op) /* only one part objects */ 291animate_turning (object *op) /* only one part objects */
325{ 292{
326 if (++op->state >= NUM_ANIMATIONS (op) / 8) 293 if (++op->state >= NUM_ANIMATIONS (op) / 8)
327 op->state = 0; 294 op->state = 0;
414{ 381{
415 op->stats.wc = state; 382 op->stats.wc = state;
416 if (state) 383 if (state)
417 { 384 {
418 use_trigger (op); 385 use_trigger (op);
419 if (op->stats.exp > 0) /* check sanity */ 386 op->set_speed (op->stats.exp > 0 ? 1. / op->stats.exp : 1.);
420 op->speed = 1.0 / op->stats.exp;
421 else
422 op->speed = 1.0;
423 update_ob_speed (op);
424 op->speed_left = -1; 387 op->speed_left = -1;
425 } 388 }
426 else 389 else
427 { 390 {
428 use_trigger (op); 391 use_trigger (op);
429 op->speed = 0; 392 op->set_speed (0);
430 update_ob_speed (op);
431 } 393 }
432} 394}
433 395
434 396
435/* 397/*
570 trigger_move (op, 0); 532 trigger_move (op, 0);
571 else 533 else
572 { 534 {
573 op->stats.wc = 0; 535 op->stats.wc = 0;
574 op->value = !op->value; 536 op->value = !op->value;
575 op->speed = 0; 537 op->set_speed (0);
576 update_ob_speed (op);
577 } 538 }
578 } 539 }
579 return 0; 540 return 0;
580 541
581 case TRIGGER: 542 case TRIGGER:
582 if (cause) 543 if (cause)
583 { 544 {
584 if (in_movement) 545 if (in_movement)
585 return 0; 546 return 0;
547
586 push = 1; 548 push = 1;
587 } 549 }
550
588 if (NUM_ANIMATIONS (op) > 1) 551 if (NUM_ANIMATIONS (op) > 1)
589 { 552 {
590 SET_ANIMATION (op, push); 553 SET_ANIMATION (op, push);
591 update_object (op, UP_OBJ_FACE); 554 update_object (op, UP_OBJ_FACE);
592 } 555 }
556
593 trigger_move (op, push); 557 trigger_move (op, push);
594 return 1; 558 return 1;
595 559
596 default: 560 default:
597 LOG (llevDebug, "Unknown trigger type: %s (%d)\n", &op->name, op->type); 561 LOG (llevDebug, "Unknown trigger type: %s (%d)\n", &op->name, op->type);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines