void songs_init() { int i; char inputline[80+1]; CFILE * fp; if ( Songs_initialized ) return; fp = cfopen( "descent.sng", "rb" ); if ( fp == NULL ) { Error( "Couldn't open descent.sng" ); } i = 0; while (cfgets(inputline, 80, fp )) { char *p = strchr(inputline,'\n'); if (p) *p = '\0'; if ( strlen( inputline ) ) { Assert( i < MAX_SONGS ); sscanf( inputline, "%s %s %s", Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file ); //printf( "%d. '%s' '%s' '%s'\n",i, Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file ); i++; } } Songs_initialized = 1; cfclose(fp); }
bool fs2netd_player_banned(net_addr *addr) { if ( !Logged_in ) { return false; } char line[32]; // no line should be larger than 16, but let's be safe char ip_str[32]; memset(ip_str, 0, 32); memset(line, 0, 32); bool retval = false; CFILE *banlist_cfg = cfopen("banlist.cfg", "rt", CFILE_NORMAL, CF_TYPE_DATA); if (banlist_cfg == NULL) { return false; } psnet_addr_to_string( ip_str, addr ); while ( !cfeof(banlist_cfg) && !retval ) { cfgets(line, 32, banlist_cfg); if ( !strnicmp(ip_str, line, strlen(line)) ) { retval = true; // BANNINATED!!! } } cfclose(banlist_cfg); return retval; }
// given a valid XSTR() id#, lookup the string in tstrings.tbl, filling in out if found, nonzero on success int lcl_ext_lookup(char *out, int id) { char text[1024]; int ret; int pointer; Assert(Lcl_pointer_count >= 0); Assert(Lcl_pointers[0] >= 0); Assert(Lcl_pointers[Lcl_pointer_count - 1] >= 0); Assert(Lcl_ext_file != NULL); Assert(id >= 0); // seek to the closest pointer <= the id# we're looking for pointer = id / LCL_GRANULARITY; cfseek(Lcl_ext_file, Lcl_pointers[pointer], CF_SEEK_SET); // reset parsing vars and go to town Ts_current_state = TS_SCANNING; Ts_id_text_size = 0; Ts_text_size; memset(Ts_text, 0, PARSE_TEXT_STRING_LEN); memset(Ts_id_text, 0, PARSE_ID_STRING_LEN); while((cftell(Lcl_ext_file) < Lcl_pointers[Lcl_pointer_count - 1]) && cfgets(text, 1024, Lcl_ext_file)){ ret = lcl_ext_lookup_sub(text, out, id); // run the line parse function switch(ret & 0x0fffffff){ // error case 0 : Int3(); // should never get here - it means the string doens't exist in the table!! return 0; // success parsing the line - please continue case 1 : break; // found a matching string/id pair case 2 : // success if (Lcl_gr) { // this is because tstrings.tbl reads in as ANSI for some reason // opening tstrings with "rb" mode didnt seem to help, so its now still "rt" like before lcl_fix_umlauts(out, LCL_TO_ASCII); } return 1; // end of language found case 3 : Int3(); // should never get here - it means the string doens't exist in the table!! return 0; } } Int3(); // should never get here - it means the string doens't exist in the table!! return 0; }
bool fs2netd_player_banned(net_addr *addr) { // don't bother with this if we aren't on FS2NetD if ( !Om_tracker_flag ) { return false; } if ( !(Game_mode & GM_MULTIPLAYER) ) { return false; } if ( !Is_connected ) { return false; } char line[32]; // no line should be larger than 16, but let's be safe char ip_str[32]; memset(ip_str, 0, 32); memset(line, 0, 32); bool retval = false; CFILE *banlist_cfg = cfopen("banlist.cfg", "rt", CFILE_NORMAL, CF_TYPE_DATA); if (banlist_cfg == NULL) { return false; } psnet_addr_to_string( ip_str, addr ); while ( !cfeof(banlist_cfg) && !retval ) { cfgets(line, 32, banlist_cfg); if ( !strnicmp(ip_str, line, strlen(line)) ) { retval = true; // BANNINATED!!! } } cfclose(banlist_cfg); return retval; }
char *fgets_unlimited(PHYSFS_file *f) { int mem = 256; char *word, *buf, *p; MALLOC(word, char, mem); p = word; while (word && cfgets(p, mem, f) == word + mem) { int i; // Make a bigger buffer, because it read to the end of the buffer. buf = word; mem *= 2; MALLOC(word, char, mem); for (i = 0; i < mem/2; i++) word[i] = buf[i]; d_free(buf); p = word + mem/2; } return word; }
//called for each level to load & setup the exit sequence load_endlevel_data(int level_num) { char filename[13]; char line[LINE_LEN],*p; CFILE *ifile; int var,segnum,sidenum; int exit_side, i; int have_binary = 0; endlevel_data_loaded = 0; //not loaded yet try_again: ; if (level_num<0) //secret level strcpy(filename,Secret_level_names[-level_num-1]); else //normal level strcpy(filename,Level_names[level_num-1]); if (!convert_ext(filename,"END")) return; ifile = cfopen(filename,"rb"); if (!ifile) { convert_ext(filename,"TXB"); ifile = cfopen(filename,"rb"); if (!ifile) if (level_num==1) { return; //abort //Error("Cannot load file text of binary version of <%s>",filename); } else { level_num = 1; goto try_again; } have_binary = 1; } //ok...this parser is pretty simple. It ignores comments, but //everything else must be in the right place var = 0; while (cfgets(line,LINE_LEN,ifile)) { if (have_binary) { for (i = 0; i < strlen(line) - 1; i++) { encode_rotate_left(&(line[i])); line[i] = line[i] ^ BITMAP_TBL_XOR; encode_rotate_left(&(line[i])); } p = line; } if ((p=strchr(line,';'))!=NULL) *p = 0; //cut off comment for (p=line+strlen(line)-1;p>line && isspace(*p);*p--=0); for (p=line;isspace(*p);p++); if (!*p) //empty line continue; switch (var) { case 0: { //ground terrain int iff_error; ubyte pal[768]; if (terrain_bm_instance.bm_data) free(terrain_bm_instance.bm_data); iff_error = iff_read_bitmap(p,&terrain_bm_instance,BM_LINEAR,pal); if (iff_error != IFF_NO_ERROR) { mprintf((1, "File %s - IFF error: %s",p,iff_errormsg(iff_error))); Error("File %s - IFF error: %s",p,iff_errormsg(iff_error)); } terrain_bitmap = &terrain_bm_instance; gr_remap_bitmap_good( terrain_bitmap, pal, iff_transparent_color, -1); break; } case 1: //height map load_terrain(p); break; case 2: sscanf(p,"%d,%d",&exit_point_bmx,&exit_point_bmy); break; case 3: //exit heading exit_angles.h = i2f(atoi(p))/360; break; case 4: { //planet bitmap int iff_error; ubyte pal[768]; if (satellite_bm_instance.bm_data) free(satellite_bm_instance.bm_data); iff_error = iff_read_bitmap(p,&satellite_bm_instance,BM_LINEAR,pal); if (iff_error != IFF_NO_ERROR) { mprintf((1, "File %s - IFF error: %s",p,iff_errormsg(iff_error))); Error("File %s - IFF error: %s",p,iff_errormsg(iff_error)); } satellite_bitmap = &satellite_bm_instance; gr_remap_bitmap_good( satellite_bitmap, pal, iff_transparent_color, -1); break; } case 5: //earth pos case 7: { //station pos vms_matrix tm; vms_angvec ta; int pitch,head; sscanf(p,"%d,%d",&head,&pitch); ta.h = i2f(head)/360; ta.p = -i2f(pitch)/360; ta.b = 0; vm_angles_2_matrix(&tm,&ta); if (var==5) satellite_pos = tm.fvec; //vm_vec_copy_scale(&satellite_pos,&tm.fvec,SATELLITE_DIST); else station_pos = tm.fvec; break; } case 6: //planet size satellite_size = i2f(atoi(p)); break; } var++; } Assert(var == NUM_VARS); // OK, now the data is loaded. Initialize everything //find the exit sequence by searching all segments for a side with //children == -2 for (segnum=0,exit_segnum=-1;exit_segnum==-1 && segnum<=Highest_segment_index;segnum++) for (sidenum=0;sidenum<6;sidenum++) if (Segments[segnum].children[sidenum] == -2) { exit_segnum = segnum; exit_side = sidenum; break; } Assert(exit_segnum!=-1); compute_segment_center(&mine_exit_point,&Segments[exit_segnum]); extract_orient_from_segment(&mine_exit_orient,&Segments[exit_segnum]); compute_center_point_on_side(&mine_side_exit_point,&Segments[exit_segnum],exit_side); vm_vec_scale_add(&mine_ground_exit_point,&mine_exit_point,&mine_exit_orient.uvec,-i2f(20)); //compute orientation of surface { vms_vector tv; vms_matrix exit_orient,tm; vm_angles_2_matrix(&exit_orient,&exit_angles); vm_transpose_matrix(&exit_orient); vm_matrix_x_matrix(&surface_orient,&mine_exit_orient,&exit_orient); vm_copy_transpose_matrix(&tm,&surface_orient); vm_vec_rotate(&tv,&station_pos,&tm); vm_vec_scale_add(&station_pos,&mine_exit_point,&tv,STATION_DIST); vm_vec_rotate(&tv,&satellite_pos,&tm); vm_vec_scale_add(&satellite_pos,&mine_exit_point,&tv,SATELLITE_DIST); vm_vector_2_matrix(&tm,&tv,&surface_orient.uvec,NULL); vm_vec_copy_scale(&satellite_upvec,&tm.uvec,SATELLITE_HEIGHT); } cfclose(ifile); endlevel_data_loaded = 1; }
void menubar_init( char * file ) { int i,j, np; int aw, w, h; CFILE * infile; char buffer[200]; char buf1[200]; char buf2[200]; int menu, item; num_menus = state = 0; for (i=0; i < MAXMENUS; i++ ) { Menu[i].x = Menu[i].y = Menu[i].w = Menu[i].h = 0; Menu[i].ShowBar = 0; Menu[i].CurrentItem = 0; Menu[i].NumItems = 0; Menu[i].Displayed = 0; Menu[i].Background = 0; for (j=0; j< MAXITEMS; j++ ) { Menu[i].Item[j].x = Menu[i].Item[j].y = Menu[i].Item[j].w = Menu[i].Item[j].h = 0; Menu[i].Item[j].Text = NULL; Menu[i].Item[j].Hotkey = -1; Menu[i].Item[j].user_function = NULL; } } infile = cfopen( file, "rt" ); if (!infile) return; while ( cfgets( buffer, 200, infile) != NULL ) { if ( buffer[0] == ';' ) continue; //mprintf( 0, "%s\n", buffer ); CommaParse( 0, buf1, buffer ); menu = atoi( buf1 ); if (menu >= MAXMENUS) Error("Too many menus (%d).",menu); CommaParse( 1, buf1, buffer ); item = atoi(buf1 ); if (item >= MAXITEMS) Error("Too many items (%d) in menu %d.",item+1,menu); CommaParse( 2, buf1, buffer ); ul_xlate(buf1); if (buf1[0] != '-' ) { sprintf( buf2, " %s ", buf1 ); Menu[menu].Item[item].Text = d_strdup(buf2); } else Menu[menu].Item[item].Text = d_strdup(buf1); Menu[menu].Item[item].InactiveText = d_strdup(Menu[menu].Item[item].Text); j= 0; for (i=0; i<=strlen(Menu[menu].Item[item].Text); i++ ) { np = Menu[menu].Item[item].Text[i]; if (np != CC_UNDERLINE) Menu[menu].Item[item].InactiveText[j++] = np; } CommaParse( 3, buf1, buffer ); if (buf1[0]=='{' && buf1[1] =='}') Menu[menu].Item[item].Hotkey = -1; else { i = DecodeKeyText(buf1); if (i<1) { Error("Unknown key, %s, in %s\n", buf1, file ); } else { Menu[menu].Item[item].Hotkey = i; } } CommaParse( 4, buf1, buffer ); if (strlen(buf1)) { Menu[menu].Item[item].user_function = func_get(buf1, &np); // if (!strcmp(buf1,"do-wall-dialog")) { // mprintf( 0, "Found function %s\n", buf1); // mprintf( 0, "User function %s\n", Menu[menu].Item[item].user_function); // } if (Menu[menu].Item[item].user_function==NULL) { Error( "Unknown function, %s, in %s\n", buf1, file ); //ui_messagebox( -2, -2, 1, buffer, "Ok" ); } } Menu[menu].Item[item].x = Menu[menu].x; Menu[menu].Item[item].y = Menu[menu].y; if ( Menu[menu].Item[item].Text[0] == '-' ) { w = 1; h = 3; } else { gr_get_string_size( Menu[menu].Item[item].Text, &w, &h, &aw ); w += 2; h += 2; } if (menu==0) { Menu[0].h = h; Menu[0].Item[item].x = Menu[0].x + Menu[0].w; Menu[0].Item[item].y = Menu[0].y; Menu[item+1].x = Menu[0].x + Menu[0].w; Menu[item+1].y = Menu[0].h - 2; Menu[0].Item[item].w = w; Menu[0].Item[item].h = h; Menu[0].w += w; }else { if ( w > Menu[menu].w ) { Menu[menu].w = w; for (i=0; i< Menu[menu].NumItems; i++ ) Menu[menu].Item[i].w = Menu[menu].w; } Menu[menu].Item[item].w = Menu[menu].w; Menu[menu].Item[item].x = Menu[menu].x; Menu[menu].Item[item].y = Menu[menu].y+Menu[menu].h; Menu[menu].Item[item].h = h; Menu[menu].h += h; } if ( item >= Menu[menu].NumItems ) { Menu[menu].NumItems = item+1; } if ( menu >= num_menus ) num_menus = menu+1; } Menu[0].w = 700; cfclose( infile ); for (i=0; i<num_menus; i++ ) Menu[i].Background = gr_create_bitmap(Menu[i].w, Menu[i].h ); menubar_hid = 1; }
void read_menu_tbl(char* menu_name, char* bkg_filename, char* mask_filename, MENU_REGION* regions, int* num_regions, int play_sound) { CFILE* fp; int state=0; char* p1, *p2, *p3; //char music_filename[128]; char seps[] = NOX(" ,\t"); char *token; char tmp_line[132]; *num_regions=0; // open localization lcl_ext_open(); fp = cfopen( NOX("menu.tbl"), "rt" ); if (fp == NULL) { Error(LOCATION, "menu.tbl could not be opened\n"); // close localization lcl_ext_close(); return; } while (cfgets(tmp_line, 132, fp)) { p1 = strchr(tmp_line,'\n'); if (p1) *p1 = '\0'; p1 = strchr(tmp_line,';'); if (p1) *p1 = '\0'; p1 = p3 = strchr( tmp_line, '[' ); if (p3 && state == 1) { // close localization lcl_ext_close(); cfclose(fp); return; } if ( p1 || p3) { if (!state) { p2 = strchr( tmp_line, ']' ); if (p2) *p2 = 0; if (!stricmp( ++p1, menu_name )) state = 1; } else { cfclose(fp); break; } } else if (state) { // parse a region line p1 = strchr( tmp_line, '\"' ); if (p1) { p2 = strchr( tmp_line+1, '\"' ); if (!p2) { nprintf(("Warning","Error parsing menu file\n")); // close localization lcl_ext_close(); return; } *p2 = 0; strcpy(regions[*num_regions].text,++p1); p2++; // get the tokens mask number token = strtok( p2, seps ); regions[*num_regions].mask = atoi(token); // get the hot key character token = strtok( NULL, seps ); regions[*num_regions].key = token[0]; // stuff default click sound (not in menu.tbl) if ( play_sound ) { regions[*num_regions].click_sound = SND_IFACE_MOUSE_CLICK; } else { regions[*num_regions].click_sound = -1; } *num_regions = *num_regions + 1; } else { // get the menu filenames // Establish string and get the first token token = strtok( tmp_line, seps ); if ( token != NULL ) { // store the background filename strcpy(bkg_filename, token); // get the mask filename token = strtok( NULL, seps ); strcpy(mask_filename, token); } } } } cfclose(fp); // close localization lcl_ext_close(); }
// initialize the pointer array into tstrings.tbl (call from lcl_ext_open() ONLY) void lcl_ext_setup_pointers() { char language_string[128]; char line[1024]; char *tok; int string_count; int ret; int found_start = 0; // open the localization file lcl_ext_open(); if(Lcl_ext_file == NULL){ error_display(0, "Error opening externalization file! File likely does not exist or could not be found"); return; } // seek to the currently active language memset(language_string, 0, 128); strcpy(language_string, "#"); if(!stricmp(DEFAULT_LANGUAGE, Lcl_languages[Lcl_current_lang].lang_name)){ strcat(language_string, "default"); } else { strcat(language_string, Lcl_languages[Lcl_current_lang].lang_name); } memset(line, 0, 1024); // reset seek variables and begin Lcl_pointer_count = 0; while(cfgets(line, 1024, Lcl_ext_file)){ tok = strtok(line, " \n"); if(tok == NULL){ continue; } // if the language matches, we're good to start parsing strings if(!stricmp(language_string, tok)){ found_start = 1; break; } } // if we didn't find the language specified, error if(found_start <= 0){ error_display(0, "Could not find specified langauge in tstrings.tbl!\n"); lcl_ext_close(); return; } string_count = 0; while(cfgets(line, 1024, Lcl_ext_file)){ ret = lcl_ext_lookup_sub(line, NULL, -1); // do stuff switch(ret & 0x0fffffff){ // error case 0 : lcl_ext_close(); return; // end of language found case 3 : // mark one final pointer Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1; lcl_ext_close(); return; } // the only other case we care about is the beginning of a new id# if(ret & (1<<31)){ if((string_count % LCL_GRANULARITY) == 0){ // mark the pointer down Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1; // if we're out of pointer slots if(Lcl_pointer_count >= LCL_MAX_POINTERS){ error_display(0, "Out of pointer for tstrings.tbl lookup. Please increment LCL_MAX_POINTERS in localize.cpp"); lcl_ext_close(); return; } } // increment string count string_count++; } } // should never get here. we should always be exiting through case 3 (end of language section) of the above switch // statement Int3(); lcl_ext_close(); }
void multi_options_read_config() { CFILE *in; char str[512]; char *tok = NULL; // set default value for the global multi options Multi_options_g.reset(); ushort forced_port = (ushort)os_config_read_uint(NULL, "ForcePort", 0); Multi_options_g.port = (Cmdline_network_port >= 0) ? (ushort)Cmdline_network_port : forced_port == 0 ? (ushort)DEFAULT_GAME_PORT : forced_port; Multi_options_g.log = (Cmdline_multi_log) ? 1 : 0; // read in the config file in = cfopen(MULTI_CFG_FILE, "rt", CFILE_NORMAL, CF_TYPE_DATA); // if we failed to open the config file, user default settings if (in == NULL) { nprintf(("Network","Failed to open network config file, using default settings\n")); } else { while ( !cfeof(in) ) { // read in the game info memset(str, 0, 512); cfgets(str, 512, in); // parse the first line tok = strtok(str, " \t"); // check the token if (tok != NULL) { drop_leading_white_space(tok); drop_trailing_white_space(tok); } else { continue; } // all possible options // only standalone cares about the following options if (Is_standalone) { // setup PXO mode if ( SETTING("+pxo") ) { NEXT_TOKEN(); if (tok != NULL) { strncpy(Multi_fs_tracker_channel, tok, MAX_PATH-1); } } else // set the standalone server's permanent name if ( SETTING("+name") ) { NEXT_TOKEN(); if (tok != NULL) { strncpy(Multi_options_g.std_pname, tok, STD_NAME_LEN); } } else // standalone won't allow voice transmission if ( SETTING("+no_voice") ) { Multi_options_g.std_voice = 0; } else // set the max # of players on the standalone if ( SETTING("+max_players") ) { NEXT_TOKEN(); if (tok != NULL) { if ( !((atoi(tok) < 1) || (atoi(tok) > MAX_PLAYERS)) ) { Multi_options_g.std_max_players = atoi(tok); } } } else // ban a player if ( SETTING("+ban") ) { NEXT_TOKEN(); if (tok != NULL) { std_add_ban(tok); } } else // set the standalone host password if ( SETTING("+passwd") ) { NEXT_TOKEN(); if (tok != NULL) { strncpy(Multi_options_g.std_passwd, tok, STD_PASSWD_LEN); #ifdef _WIN32 // yuck extern HWND Multi_std_host_passwd; SetWindowText(Multi_std_host_passwd, Multi_options_g.std_passwd); #else // TODO: get password ? // argh, gonna have to figure out how to do this - mharris 07/07/2002 #endif } } else // set standalone to low updates if ( SETTING("+low_update") ) { Multi_options_g.std_datarate = OBJ_UPDATE_LOW; } else // set standalone to medium updates if ( SETTING("+med_update") ) { Multi_options_g.std_datarate = OBJ_UPDATE_MEDIUM; } else // set standalone to high updates if ( SETTING("+high_update") ) { Multi_options_g.std_datarate = OBJ_UPDATE_HIGH; } else // set standalone to high updates if ( SETTING("+lan_update") ) { Multi_options_g.std_datarate = OBJ_UPDATE_LAN; } else // use pxo flag if ( SETTING("+use_pxo") ) { Om_tracker_flag = 1; } else // standalone pxo login user if ( SETTING("+pxo_login") ) { NEXT_TOKEN(); if (tok != NULL) { strncpy(Multi_options_g.std_pxo_login, tok, MULTI_TRACKER_STRING_LEN); } } else // standalone pxo login password if ( SETTING("+pxo_password") ) { NEXT_TOKEN(); if (tok != NULL) { strncpy(Multi_options_g.std_pxo_password, tok, MULTI_TRACKER_STRING_LEN); } } else if ( SETTING("+webui_root") ) { NEXT_TOKEN(); if (tok != NULL) { Multi_options_g.webuiRootDirectory = SCP_string(tok); } } else if ( SETTING("+webapi_username") ) { NEXT_TOKEN(); if (tok != NULL) { Multi_options_g.webapiUsername = SCP_string(tok); } } else if ( SETTING("+webapi_password") ) { NEXT_TOKEN(); if (tok != NULL) { Multi_options_g.webapiPassword = SCP_string(tok); } } else if ( SETTING("+webapi_server_port") ) { NEXT_TOKEN(); if (tok != NULL) { long int result = strtol(tok, NULL, 10); if(result <= 0 || result > USHRT_MAX) { mprintf(("ERROR: Invalid or out of range webapi_server_port '%s' specified in multi.cfg, must be integer between 1024 and %i.\n", tok, USHRT_MAX)); } else if(result < 1024) { mprintf(("ERROR: webapi_server_port '%ld' in multi.cfg is too low, must be between 1024 and %d.\n", result, USHRT_MAX)); } else { mprintf(("Using webapi_server_port '%ld' from multi.cfg.\n", result)); Multi_options_g.webapiPort = (ushort) result; } } } } // ... common to all modes ... // ip addr of user tracker if ( SETTING("+user_server") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.user_tracker_ip, tok); } } else // ip addr of game tracker if ( SETTING("+game_server") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.game_tracker_ip, tok); } } else // port to use for the game/user tracker (FS2NetD) if ( SETTING("+server_port") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.tracker_port, tok); } } else // ip addr of pxo chat server if ( SETTING("+chat_server") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.pxo_ip, tok); } } else // url of pilot rankings page if ( SETTING("+rank_url") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.pxo_rank_url, tok); } } else // url of pxo account create page if ( SETTING("+create_url") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.pxo_create_url, tok); } } else // url of pxo account verify page if ( SETTING("+verify_url") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.pxo_verify_url, tok); } } else // url of pxo banners if ( SETTING("+banner_url") ) { NEXT_TOKEN(); if (tok != NULL) { strcpy_s(Multi_options_g.pxo_banner_url, tok); } } else // set the max datarate for high updates if ( SETTING("+datarate") ) { NEXT_TOKEN(); if (tok != NULL) { if ( atoi(tok) >= 4000 ) { Multi_options_g.datarate_cap = atoi(tok); } } } else // get the proxy server if ( SETTING("+http_proxy") ) { NEXT_TOKEN(); if (tok != NULL) { char *ip = strtok(tok, ":"); if (ip != NULL) { strcpy_s(Multi_options_proxy, ip); } ip = strtok(NULL, ""); if (ip != NULL) { Multi_options_proxy_port = (ushort)atoi(ip); } else { strcpy_s(Multi_options_proxy, ""); } } } } // close the config file cfclose(in); in = NULL; } #ifndef _WIN32 if (Is_standalone) { std_configLoaded(&Multi_options_g); } #endif }
void credits_show() { int i, j, l, done; CFILE * file; char buffer[NUM_LINES][80]; grs_bitmap backdrop; ubyte backdrop_palette[768]; int pcx_error; int buffer_line = 0; fix last_time; fix time_delay = 4180 / f2fl(Scale_y); // ~ F1_0 / 12.9 int first_line_offset,extra_inc=0; int have_bin_file = 0; char * tempp; grs_point scale_pts[] = FULLSCREEN_SCALE_PTS; ubyte *fade_values = malloc(grd_curscreen->sc_h); for (i = 0; i < grd_curscreen->sc_h; ++i) { fade_values[i] = fade_values_200[(int)(((float)i / (float)grd_curscreen->sc_h) * 200)]; } set_screen_mode(SCREEN_MENU); // Clear out all tex buffer lines. for (i=0; i<NUM_LINES; i++ ) buffer[i][0] = 0; have_bin_file = 0; file = cfopen( "credits.tex", "rb" ); if (file == NULL) { file = cfopen("credits.txb", "rb"); if (file == NULL) Error("Missing CREDITS.TEX and CREDITS.TXB file\n"); have_bin_file = 1; } gr_use_palette_table( "credits.256" ); header_font = gr_init_font( "font1-1.fnt" ); title_font = gr_init_font( "font2-3.fnt" ); names_font = gr_init_font( "font2-2.fnt" ); backdrop.bm_data=NULL; pcx_error = pcx_read_bitmap("stars.pcx",&backdrop,BM_LINEAR,backdrop_palette); if (pcx_error != PCX_ERROR_NONE) { cfclose(file); return; } songs_play_song( SONG_CREDITS, 0 ); gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 ); gr_set_current_canvas(NULL); scale_bitmap(&backdrop,scale_pts); gr_palette_fade_in( gr_palette, 32, 0 ); vfx_set_palette_sub( gr_palette ); //gr_clear_canvas(BM_XRGB(0,0,0)); key_flush(); last_time = timer_get_fixed_seconds(); done = 0; first_line_offset = 0; while( 1 ) { int k; do { buffer_line = (buffer_line+1) % NUM_LINES; if (cfgets( buffer[buffer_line], 80, file )) { char *p; if (have_bin_file) { // is this a binary tbl file for (i = 0; i < strlen(buffer[buffer_line]) - 1; i++) { encode_rotate_left(&(buffer[buffer_line][i])); buffer[buffer_line][i] ^= BITMAP_TBL_XOR; encode_rotate_left(&(buffer[buffer_line][i])); } } p = strchr(&buffer[buffer_line][0],'\n'); if (p) *p = '\0'; } else { //fseek( file, 0, SEEK_SET); buffer[buffer_line][0] = 0; done++; } } while (extra_inc--); extra_inc = 0; for (i=0; i<ROW_SPACING; i++ ) { int y; y = first_line_offset - i; #ifndef OGLES gr_set_current_canvas(VR_offscreen_buffer); #endif scale_bitmap(&backdrop, scale_pts); for (j=0; j<NUM_LINES; j++ ) { char *s; l = (buffer_line + j + 1 ) % NUM_LINES; s = buffer[l]; if ( s[0] == '!' ) { s++; } else if ( s[0] == '$' ) { grd_curcanv->cv_font = header_font; s++; } else if ( s[0] == '*' ) { grd_curcanv->cv_font = title_font; s++; } else grd_curcanv->cv_font = names_font; gr_bitblt_fade_table = fade_values; tempp = strchr( s, '\t' ); if ( tempp ) { int w, h, aw; *tempp = 0; gr_get_string_size( s, &w, &h, &aw ); w *= f2fl(Scale_x); h *= f2fl(Scale_y); gr_scale_printf( (160-w)/2, y, Scale_factor, Scale_factor, s ); gr_get_string_size( &tempp[1], &w, &h, &aw ); w *= f2fl(Scale_x); h *= f2fl(Scale_y); gr_scale_printf( 160+((160-w)/2), y, Scale_factor, Scale_factor, &tempp[1] ); *tempp = '\t'; } else { gr_scale_printf( 0x8000, y, Scale_factor, Scale_factor, s ); } gr_bitblt_fade_table = NULL; if (buffer[l][0] == '!') y += ROW_SPACING/2; else y += ROW_SPACING; } #ifdef OGLES showRenderBuffer(); #else gr_bm_ubitblt(grd_curscreen->sc_w, grd_curscreen->sc_h, 0, 0, 0, 0, &(VR_offscreen_buffer->cv_bitmap), &(grd_curscreen->sc_canvas.cv_bitmap) ); #endif while( timer_get_fixed_seconds() < last_time+time_delay ); last_time = timer_get_fixed_seconds(); k = key_inkey(); #ifndef NDEBUG if (k == KEY_BACKSP) { Int3(); k=0; } #endif // { // fix ot = time_delay; // time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100; // if (ot!=time_delay) { // mprintf( (0, "[%x] ", time_delay )); // } // } if (k == KEY_PRINT_SCREEN) { save_screen_shot(0); k = 0; } if ((k>0)||(done>NUM_LINES)) { gr_close_font(header_font); gr_close_font(title_font); gr_close_font(names_font); gr_palette_fade_out( gr_palette, 32, 0 ); gr_use_palette_table( "palette.256" ); free(backdrop.bm_data); cfclose(file); songs_play_song( SONG_TITLE, 1 ); return; } } if (buffer[(buffer_line + 1 ) % NUM_LINES][0] == '!') { first_line_offset -= ROW_SPACING-ROW_SPACING/2; if (first_line_offset <= -ROW_SPACING) { first_line_offset += ROW_SPACING; extra_inc++; } } } free(fade_values); }
void songs_init() { int i; char inputline[80+1]; CFILE * fp; fp = cfopen( "descent.sng", "rb" ); if ( fp == NULL ) { int i; for (i = 0; i < SONG_LEVEL_MUSIC + NUM_GAME_SONGS; i++) { strcpy(Songs[i].melodic_bank_file, "melodic.bnk"); strcpy(Songs[i].drum_bank_file, "drum.bnk"); if (i >= SONG_LEVEL_MUSIC) { sprintf(Songs[i].filename, "game%02d.hmp", i - SONG_LEVEL_MUSIC + 1); if (!digi_music_exists(Songs[i].filename)) sprintf(Songs[i].filename, "game%d.hmp", i - SONG_LEVEL_MUSIC); if (!digi_music_exists(Songs[i].filename)) { Songs[i].filename[0] = '\0'; // music not available break; } } } strcpy(Songs[SONG_TITLE].filename, "descent.hmp"); strcpy(Songs[SONG_BRIEFING].filename, "briefing.hmp"); strcpy(Songs[SONG_CREDITS].filename, "credits.hmp"); strcpy(Songs[SONG_ENDLEVEL].filename, "endlevel.hmp"); // can't find it? give a warning strcpy(Songs[SONG_ENDGAME].filename, "endgame.hmp"); // ditto cGameSongsAvailable = i - SONG_LEVEL_MUSIC; return; } i = 0; while (cfgets(inputline, 80, fp )) { char *p = strchr(inputline,'\n'); if (p) *p = '\0'; if ( strlen( inputline ) ) { Assert( i < MAX_SONGS ); sscanf( inputline, "%15s %15s %15s", Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file ); i++; } } // HACK: If Descent.hog is patched from 1.0 to 1.5, descent.sng is broken and will not exceed 12 songs. So let's HACK it here. if (i==12) { sprintf(Songs[i].filename,"game08.hmp"); sprintf(Songs[i].melodic_bank_file,"rickmelo.bnk"); sprintf(Songs[i].drum_bank_file,"rickdrum.bnk"); i++; sprintf(Songs[i].filename,"game09.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game10.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game11.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game12.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game13.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game14.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game15.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game16.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game17.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game18.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game19.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game20.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game21.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game22.hmp"); sprintf(Songs[i].melodic_bank_file,"hammelo.bnk"); sprintf(Songs[i].drum_bank_file,"hamdrum.bnk"); i++; } cGameSongsAvailable = i - SONG_LEVEL_MUSIC; Songs_initialized = 1; cfclose(fp); if ( Songs_initialized ) return; // RBA Hook #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) ) if (GameCfg.SndEnableRedbook) { RBAInit(); set_redbook_volume(GameCfg.MusicVolume); } #endif // endof ifndef SHAREWARE, ie ifdef SHAREWARE }