void remove_sent (object_t * ob, object_t * user) { sentence_t **s; if (!(user->flags & O_ENABLE_COMMANDS)) return; for (s = &user->sent; *s;) { sentence_t *tmp; if ((*s)->ob == ob) { #ifdef DEBUG if (!((*s)->flags & V_FUNCTION)) debug(d_flag, ("--Unlinking sentence %s\n", (*s)->function.s)); #endif tmp = *s; *s = tmp->next; free_sentence(tmp); illegal_sentence_action = 2; illegal_sentence_ob = ob; } else s = &((*s)->next); } }
/* * Remove sentence with specified verb and action. Return 1 * if success. If command_giver, remove his action, otherwise * remove current_object's action. */ static int remove_action (const char *act, const char *verb) { object_t *ob; sentence_t **s; if (command_giver) ob = command_giver; else ob = current_object; if (ob) { for (s = &ob->sent; *s; s = &((*s)->next)) { sentence_t *tmp; if (((*s)->ob == current_object) && (!((*s)->flags & V_FUNCTION)) && !strcmp((*s)->function.s, act) && !strcmp((*s)->verb, verb)) { tmp = *s; *s = tmp->next; free_sentence(tmp); illegal_sentence_action = 1; illegal_sentence_ob = current_object; return 1; } } } return 0; }
/* If there is room for more sentences, add one. */ static void more_sentences (state *s) { int i; Bool any = False; for (i = 0; i < s->nsentences; i++) { sentence *se = s->sentences[i]; if (! se) { se = new_sentence (s, s); populate_sentence (s, se); if (se->nwords > 0) s->spawn_p = False, any = True; else { free_sentence (s, se); se = 0; } s->sentences[i] = se; if (se) s->latest_sentence = se->id; break; } } if (any) sort_sentences (s); }
static int remove_get_char (object_t * ob){ int ret; if (!ob || ob->interactive == 0){ ret = -2; } else ret = 0; if (ob->interactive->input_to) { ret = 1; free_sentence(ob->interactive->input_to); if (ob->interactive->num_carry > 0) free_some_svalues(ob->interactive->carryover, ob->interactive->num_carry); ob->interactive->carryover = NULL; ob->interactive->num_carry = 0; ob->interactive->input_to = 0; } else { ret = -1; } return ret; }
/* * Remove an interactive player immediately. */ void remove_interactive(struct interactive *ip, int link_dead) { struct object *save = command_giver; struct object *ob = ip->ob; int i; if (!ob || !(ob->interactive)) return; for (i = 0; i < MAX_PLAYERS; i++) { if (all_players[i] != ob->interactive) continue; if (ob->interactive->closing) fatal("Double call to remove_interactive()\n"); command_giver = ob; if (ob->interactive->ed_buffer) { extern void save_ed_buffer(void); /* This will call 'get_ed_buffer_save_file_name' in master_ob * If that fails(error in LPC) the closing IP will hang and * on the next read a 'fatal read on closing socket will occur' * unless we do this here before ip->closing = 1 */ (void)add_message("Saving editor buffer.\n"); save_ed_buffer(); } if (ob->interactive == NULL) return; ob->interactive->closing = 1; if (ob->interactive->snoop_by) { ob->interactive->snoop_by->snoop_on = 0; ob->interactive->snoop_by = 0; } if (ob->interactive->snoop_on) { ob->interactive->snoop_on->snoop_by = 0; ob->interactive->snoop_on = 0; } write_socket("Closing down.\n", ob); telnet_detach(ob->interactive->tp); #ifdef SUPER_SNOOP if (ob->interactive->snoop_fd >= 0) { (void)close(ob->interactive->snoop_fd); ob->interactive->snoop_fd = -1; } #endif num_player--; if (ob->interactive->input_to) { free_sentence(ob->interactive->input_to); ob->interactive->input_to = 0; } if(ob->interactive->rname) free(ob->interactive->rname); if (current_interactive == ob) current_interactive = 0; free((char *)ob->interactive); ob->interactive = 0; all_players[i] = 0; free_object(ob, "remove_interactive"); push_object(ob); push_number(link_dead); (void)apply_master_ob(M_REMOVE_INTERACTIVE,2); command_giver = save; return; } fatal("Could not find and remove player %s\n", ob->name); }
/* Render all the words to the screen, and run the animation one step. */ static void draw_sentence (state *s, sentence *se) { int i; Bool moved = False; if (! se) return; for (i = 0; i < se->nwords; i++) { word *w = se->words[i]; switch (s->mode) { case PAGE: if (se->anim_state != PAUSE && w->tick <= w->nticks) { int dx = w->target_x - w->start_x; int dy = w->target_y - w->start_y; double r = sin (w->tick * M_PI / (2 * w->nticks)); w->x = w->start_x + (dx * r); w->y = w->start_y + (dy * r); w->tick++; if (se->anim_state == OUT && s->mode == PAGE) w->tick++; /* go out faster */ moved = True; } break; case SCROLL: { int dx = w->target_x - w->start_x; int dy = w->target_y - w->start_y; double r = (double) w->tick / w->nticks; w->x = w->start_x + (dx * r); w->y = w->start_y + (dy * r); w->tick++; moved = (w->tick <= w->nticks); /* Launch a new sentence when: - the front of this sentence is almost off the left edge; - the end of this sentence is almost on screen. - or, randomly */ if (se->anim_state != OUT && i == 0 && se->id == s->latest_sentence) { Bool new_p = (w->x < (s->xgwa.width * 0.4) && w->x + se->width < (s->xgwa.width * 2.1)); Bool rand_p = (new_p ? 0 : !(random() % 2000)); if (new_p || rand_p) { se->anim_state = OUT; s->spawn_p = True; # ifdef DEBUG if (s->debug_p) fprintf (stderr, "%s: OUT %d (x2 = %d%s)\n", progname, se->id, se->words[0]->x + se->width, rand_p ? " randomly" : ""); # endif } } } break; default: abort(); break; } draw_word (s, se, w); } if (moved && se->anim_state == PAUSE) abort(); if (! moved) { switch (se->anim_state) { case IN: se->anim_state = PAUSE; se->pause_tick = (se->nwords * 7 * s->linger); if (se->move_chars_p) se->pause_tick /= 5; scatter_sentence (s, se); shuffle_words (s, se); # ifdef DEBUG if (s->debug_p) fprintf (stderr, "%s: PAUSE %d\n", progname, se->id); # endif break; case PAUSE: if (--se->pause_tick <= 0) { se->anim_state = OUT; s->spawn_p = True; # ifdef DEBUG if (s->debug_p) fprintf (stderr, "%s: OUT %d\n", progname, se->id); # endif } break; case OUT: # ifdef DEBUG if (s->debug_p) fprintf (stderr, "%s: DEAD %d\n", progname, se->id); # endif { int j; for (j = 0; j < s->nsentences; j++) if (s->sentences[j] == se) s->sentences[j] = 0; free_sentence (s, se); } break; default: abort(); break; } } }