void snd_spew_info() { int idx; char txt[512] = ""; CFILE *out = cfopen("sounds.txt", "wt", CFILE_NORMAL, CF_TYPE_DATA); if(out == NULL){ return; } cfwrite_string("Sounds loaded :\n", out); // spew info for all sounds for(idx=0; idx<MAX_SOUNDS; idx++){ if(!(Sounds[idx].flags & SND_F_USED)){ continue; } sprintf(txt, "%s (%ds)\n", Sounds[idx].filename, Sounds[idx].info.duration); cfwrite_string(txt, out); } // close the outfile if(out != NULL){ cfclose(out); out = NULL; } }
// int Test_color = 0; void chatbox_add_line(const char *msg, int pid, int add_id) { int backup; int n_lines,idx; int n_chars[3]; const char *p_str[3]; // for the initial line (unindented) char msg_extra[CHATBOX_STRING_LEN]; if(!Chatbox_created){ return; } // maybe stick on who sent the message if(add_id){ if(MULTI_STANDALONE(Net_players[pid])){ sprintf(msg_extra, NOX("%s %s"), NOX("<SERVER>"), msg ); } else { sprintf(msg_extra, NOX("%s: %s"), Net_players[pid].m_player->short_callsign, msg ); } } else { strcpy_s(msg_extra,msg); } Assert(strlen(msg_extra) < (CHATBOX_STRING_LEN - 2)); // split the text up into as many lines as necessary n_lines = split_str(msg_extra, Chatbox_disp_w, n_chars, p_str, 3); Assert(n_lines != -1); // setup the first line -- be sure to clear out the line memset( Brief_chat_lines[Brief_current_add_line], 0, CHATBOX_STRING_LEN ); // add the player id # Brief_chat_lines[Brief_current_add_line][0] = (char)(pid % 16); // Brief_chat_lines[Brief_current_add_line][0] = (char)Test_color; // Test_color = (Test_color == MAX_PLAYERS - 1) ? 0 : Test_color++; // set the indent to 0 Brief_chat_indents[Brief_current_add_line] = 0; // copy in the chars strncpy(&Brief_chat_lines[Brief_current_add_line][1],p_str[0],CHATBOX_STRING_LEN - 1); if(n_chars[0] >= CHATBOX_STRING_LEN){ Brief_chat_lines[Brief_current_add_line][CHATBOX_STRING_LEN - 1] = '\0'; } else { Brief_chat_lines[Brief_current_add_line][n_chars[0] + 1] = '\0'; } // increment the total line count if we haven't reached the max already if(Num_brief_chat_lines<MAX_BRIEF_CHAT_LINES){ Num_brief_chat_lines++; } // get the index of the next string to add text to Brief_current_add_line = Brief_chat_next_index[Brief_current_add_line]; // if we have more than 1 line, re-split everything so that the rest are indented if(n_lines > 1){ // split up the string after the first break-marker n_lines = split_str(msg_extra + n_chars[0],Chatbox_disp_w - CHAT_LINE_INDENT,n_chars,p_str,3); Assert(n_lines != -1); // setup these remaining lines for(idx=0;idx<n_lines;idx++){ // add the player id# Brief_chat_lines[Brief_current_add_line][0] = (char)(pid % 16); // add the proper indent Brief_chat_indents[Brief_current_add_line] = CHAT_LINE_INDENT; // copy in the line text itself strncpy(&Brief_chat_lines[Brief_current_add_line][1],p_str[idx],CHATBOX_STRING_LEN-1); if(n_chars[idx] >= CHATBOX_STRING_LEN){ Brief_chat_lines[Brief_current_add_line][CHATBOX_STRING_LEN - 1] = '\0'; } else { Brief_chat_lines[Brief_current_add_line][n_chars[idx] + 1] = '\0'; } // increment the total line count if we haven't reached the max already if(Num_brief_chat_lines<MAX_BRIEF_CHAT_LINES){ Num_brief_chat_lines++; } // get the index of the next line to add text to Brief_current_add_line = Brief_chat_next_index[Brief_current_add_line]; } } // COMMAND LINE OPTION if(Cmdline_multi_stream_chat_to_file && Multi_chat_stream!=NULL && msg[0] != '\0'){ // stream to the file if we're supposed to cfwrite_string(msg,Multi_chat_stream); cfwrite_char('\n',Multi_chat_stream); } // if this line of text is from the player himself, automatically go to the bottom of // the chat list if(pid == MY_NET_PLAYER_NUM){ if(Num_brief_chat_lines > Chatbox_max_lines){ Brief_start_display_index = Brief_current_add_line; for(backup = 1;backup <= Chatbox_max_lines;backup++){ Brief_start_display_index = Brief_chat_prev_index[Brief_start_display_index]; } } } // if we have enough lines of text to require scrolling, scroll down by one. else { chatbox_scroll_down(); } }