void kill_map() { delete_all_nodes(); delete_all_conns(); delete_all_curves(); delete_all_points(); delete_all_fills(); delete_all_lines(); delete_all_tiles(); delete_all_objects(); free_string(map_filename); free_string(map_path); }
void clear_map() // always called when not working { delete_all_nodes(); delete_all_conns(); delete_all_curves(); delete_all_points(); delete_all_fills(); delete_all_lines(); delete_all_tiles(); delete_all_objects(); map_saved = 1; string_clear(map_filename); string_clear(map_path); char *cwd = get_current_dir_name(); string_cat_text(map_path, cwd); free(cwd); }
// runs a script // returns -1 is esc was pressed, 0 o/w int run_script(char *script, DATAFILE *d) { char buf[512]; Ttoken *token; int i; // set datafile data = d; clear_keybuf(); // init sound memory for(i = 0; i < MAX_SCRIPT_SOUNDS; i ++) active_sounds[i] = -1; // create gfx buffers swap_buffer = create_bitmap(160, 120); buffer = create_bitmap(160, 120); script_done = FALSE; while(!script_done) { // get commands from script string script = get_line(buf, script); if (buf[0] != '#' && buf[0] != '\n' && buf[0] != '\r' && buf[0] != '-') { token = tokenize(buf); if (token != NULL) { if (!stricmp(token->word, "load_map")) cmd_loadmap(get_next_word(token)); else if (!stricmp(token->word, "draw_map")) cmd_drawmap(); else if (!stricmp(token->word, "set")) cmd_set((Ttoken *)token->next); else if (!stricmp(token->word, "move")) cmd_move((Ttoken *)token->next); else if (!stricmp(token->word, "delete")) cmd_del((Ttoken *)token->next); else if (!stricmp(token->word, "run")) cmd_run((Ttoken *)token->next); else if (!stricmp(token->word, "speak")) cmd_speak((Ttoken *)token->next, 1); else if (!stricmp(token->word, "text")) cmd_speak((Ttoken *)token->next, 0); else if (!stricmp(token->word, "save_buffer")) cmd_savebmp(); else if (!stricmp(token->word, "show_bmp")) cmd_showbmp(get_next_word(token)); else if (!stricmp(token->word, "blit")) cmd_blit(); else if (!stricmp(token->word, "fade_in")) cmd_fadein(); else if (!stricmp(token->word, "fade_out")) cmd_fadeout(); else if (!stricmp(token->word, "wait")) cmd_wait(atoi(get_next_word(token))); else if (!stricmp(token->word, "play_sample")) cmd_play_sample((Ttoken *)token->next); else if (!stricmp(token->word, "stop_sample")) cmd_stop_sample((Ttoken *)token->next); else if (!stricmp(token->word, "end_script")) cmd_end(); else { char msg[256]; sprintf(msg, "unknown: %s", token->word); msg_box(msg); } flush_tokens(token); } } } // destroy buffers delete_all_objects(); destroy_bitmap(buffer); destroy_bitmap(swap_buffer); // stop old sounds for(i = 0; i < MAX_SCRIPT_SOUNDS; i ++) { if (active_sounds[i] != -1) { stop_sound_id(active_sounds[i]); forget_sound(active_sounds[i]); } } return (script_done == -1 ? -1 : 0); }