void opengl_light_init() { opengl_calculate_ambient_factor(); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); glMaterialf(GL_FRONT, GL_SHININESS, Cmdline_ogl_spec /*80.0f*/ ); // more realistic lighting model glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); glGetIntegerv(GL_MAX_LIGHTS, &GL_max_lights); // Get the max number of lights supported // allocate memory for enabled lights Verify(GL_max_lights > 0); if ( opengl_lights == NULL ) opengl_lights = (opengl_light *) vm_malloc_q(MAX_LIGHTS * sizeof(opengl_light)); if (opengl_lights == NULL) Error( LOCATION, "Unable to allocate memory for lights!\n"); memset( opengl_lights, 0, MAX_LIGHTS * sizeof(opengl_light) ); }
void obj_reset_pairs() { int i; // mprintf(( "Resetting object pairs...\n" )); pair_used_list.a = pair_used_list.b = NULL; pair_used_list.next = NULL; pair_free_list.a = pair_free_list.b = NULL; Num_pairs = 0; if (Obj_pairs != NULL) { vm_free(Obj_pairs); Obj_pairs = NULL; } Obj_pairs = (obj_pair*) vm_malloc_q( sizeof(obj_pair) * MIN_PAIRS ); if ( Obj_pairs == NULL ) { mprintf(("Unable to create space for collision pairs!!\n")); return; } Num_pairs_allocated = MIN_PAIRS; memset( Obj_pairs, 0, sizeof(obj_pair) * MIN_PAIRS ); for (i = 0; i < MIN_PAIRS; i++) { Obj_pairs[i].next = &Obj_pairs[i+1]; } Obj_pairs[MIN_PAIRS-1].next = NULL; pair_free_list.next = &Obj_pairs[0]; }
int fs2netd_get_valid_missions_do() { if (Local_timeout == -1) { Local_timeout = timer_get_seconds() + 30; } // get the available CRCs from the server if we need to if ( FS2NetD_file_list.empty() ) { int rc = FS2NetD_GetMissionsList(FS2NetD_file_list, do_full_packet); do_full_packet = false; // communications error if (rc < 0) { Local_timeout = -1; return 4; } // no missions if ( rc && FS2NetD_file_list.empty() ) { Local_timeout = -1; return 2; } // if timeout passes then bail on crc failure if ( timer_get_seconds() > Local_timeout ) { Local_timeout = -1; return 1; } } // we should have the CRCs, or there were no missions, so process them else { static char **file_names = NULL; static int idx = 0, count = 0; bool found = false; int file_index = 0; char valid_status = MVALID_STATUS_UNKNOWN; char full_name[MAX_FILENAME_LEN], wild_card[10]; char val_text[MAX_FILENAME_LEN+15]; uint checksum = 0; if (file_names == NULL) { // allocate filename space file_names = (char**) vm_malloc_q( sizeof(char*) * 1024 ); // 1024 files should be safe! if (file_names == NULL) { Local_timeout = -1; return 3; } memset( wild_card, 0, sizeof(wild_card) ); strcpy_s( wild_card, NOX("*") ); strcat_s( wild_card, FS_MISSION_FILE_EXT ); idx = count = cf_get_file_list(1024, file_names, CF_TYPE_MISSIONS, wild_card); } // drop idx first thing idx--; // we should be done validating, or just not have nothing to validate if (idx < 0) { for (idx = 0; idx < count; idx++) { if (file_names[idx] != NULL) { vm_free(file_names[idx]); file_names[idx] = NULL; } } vm_free(file_names); file_names = NULL; idx = count = 0; Local_timeout = -1; return 4; } // verify all filenames that we know about with their CRCs // NOTE: that this is done for one file per frame, since this is inside of a popup memset( full_name, 0, MAX_FILENAME_LEN ); strncpy( full_name, cf_add_ext(file_names[idx], FS_MISSION_FILE_EXT), sizeof(full_name) - 1 ); memset( val_text, 0, sizeof(val_text) ); snprintf( val_text, sizeof(val_text) - 1, "Validating: %s", full_name ); if (Is_standalone) { if ( std_gen_is_active() ) { std_gen_set_text(val_text, 1); } } else { popup_change_text(val_text); } cf_chksum_long(full_name, &checksum); // try and find the file file_index = multi_create_lookup_mission(full_name); found = false; if (file_index >= 0) { for (SCP_vector<file_record>::iterator fr = FS2NetD_file_list.begin(); fr != FS2NetD_file_list.end() && !found; ++fr) { if ( !stricmp(full_name, fr->name) ) { if (fr->crc32 == checksum) { found = true; valid_status = MVALID_STATUS_VALID; } else { valid_status = MVALID_STATUS_INVALID; } Multi_create_mission_list[file_index].valid_status = valid_status; } } if (found) { ml_printf("FS2NetD Mission Validation: %s => Valid!", full_name); } else { ml_printf("FS2NetD Mission Validation: %s => INVALID! -- 0x%08x", full_name, checksum); } } } return 0; }