//---------- Begin of function PlayerSchool::calc_performance_monthly -----------// void PlayerSchool::calc_performance_monthly() { calc_prestige(); //sys.yield(); calc_staff_morale(); calc_media_attitudes(); calc_administrative_performance_etc(); //sys.yield(); calc_student_performance(); //sys.yield(); for (int i=0; i<SCORE_VAR_COUNT; i++) shift_history(sub_score[i], HISTORY_MONTH_COUNT); shift_history(game_score_history,HISTORY_MONTH_COUNT); shift_history(ultimate_game_score_history,HISTORY_MONTH_COUNT); calc_ultimate_score(); }
//##### begin fred 0824 #####// //---------- Begin of function Department::next_day -----------// //! void Department::next_day() { // special case; before faculty_array.next_day() if ( info.game_day == 1 ) { for (int i=0; i<RESEARCH_STATUS_COUNT; i++) shift_history(research_m_history[i], HISTORY_MONTH_COUNT); shift_history(research_total_history, HISTORY_MONTH_COUNT); shift_history(research_direct_history, HISTORY_MONTH_COUNT); shift_history(regular_faculty_with_research, HISTORY_MONTH_COUNT); if ( info.game_month == finance.fiscal_year_start_month ) for (int i=0; i<RESEARCH_STATUS_COUNT; i++) shift_history(research_y_history[i], HISTORY_YEAR_COUNT); } //--------------------------// student_array.next_day(); faculty_array.next_day(); course_array.next_day(); // start of a trimester if ( info.game_day == player_school.trimester_array[player_school.cur_trimester].start_day && info.game_month == player_school.trimester_array[player_school.cur_trimester].start_month ) { update_history(UPDATE_TRIMESTER); } // start of a month if ( info.game_day == 1 ) { update_history(UPDATE_MONTH); sys.yield(); // start of a year if ( info.game_month == finance.fiscal_year_start_month ) { update_history(UPDATE_YEAR); // reset this variable value this->project_added_this_year = false; } } }
//----------- Begin of function Facility::update_crime --------// //! void Facility::update_crime(bool init) { static float initAdminRatio = float(finance.projected_expense_array[AC_ADMINISTRATION_N_OTHER_OPERATING_EXPENSE].this_year.total / finance.projected_total_operating_expense.this_year.total ) ; //------------------// //990106 Parking and Crime model; see design response 0805. // var 40 in response_func static float currCrime=0; int i; //------------------// const int VAR_COUNT = 4; float input[VAR_COUNT]; //------------------// const int remap[ENVIRONMENT_COUNT]={3,2,1}; input[0] = 25 * (float) remap[player_school.campus_environment]; //------------------// input[1] = (float) ((finance.projected_expense_array[AC_ADMINISTRATION_N_OTHER_OPERATING_EXPENSE].this_year.total / finance.projected_total_operating_expense.this_year.total ) / initAdminRatio); //------------------// input[2] = player_school.sub_score[S_STUDENT_MORALE][THIS_MONTH]; //------------------// input[3] = player_school.staff_morale; //------------------// input[1] = math.single_response_func(1,100,1.900f, 1.047f, input[1]); input[2] = math.dual_response_func(1, 50.1f, 100, -40.21f, -24.36f, 69.78f, 20.19f, input[2]); input[3] = math.dual_response_func(1, 51.5f, 100, -51.33f, -27.54f, 62.25f, 16.38f, input[3]); const float weight[VAR_COUNT] = { 0.40f,0.35f,0.15f,0.10f }; float newValue=0; for (i=0;i<VAR_COUNT;i++) newValue += weight[i] * input[i]; currCrime = player_school.latency_func(0.1f, newValue, currCrime); //------------------// //min & max bug chea currCrime = m.fmin(100.0f, m.fmax(0.0f,math.get_random_snd(currCrime, PSCH_SD(currCrime * 0.075f)))); shift_history(crime_index, HISTORY_MONTH_COUNT); crime_index[THIS_MONTH] = (char) player_school.latency_func(0.5f, currCrime, crime_index[THIS_MONTH]); if ( init ) { for (i = THIS_MONTH; i>=THIS_MONTH-1; i--) { crime_index[i-1] = crime_index[i]; } } }
//---------- Begin of function PlayerSchool::calc_performance_yearly -----------// void PlayerSchool::calc_performance_yearly() { shift_history(bachelor_degree, HISTORY_YEAR_COUNT); shift_history(non_ug_bachelor_degree, HISTORY_YEAR_COUNT); shift_history(master_degree, HISTORY_YEAR_COUNT); shift_history(doctor_degree, HISTORY_YEAR_COUNT); for (int y=0; y<DEGREE_TYPE_COUNT; y++) { shift_history(time_to_degree[y], HISTORY_YEAR_COUNT); shift_history(fake_disp_time_to_degree[y], HISTORY_YEAR_COUNT); shift_history(dropout_rate[y], HISTORY_YEAR_COUNT); } int i, deptCount = 0; Department* deptPtr; for ( i=department_array.size(); i>0; i-- ) { if ( department_array.is_deleted(i) ) continue; deptPtr = department_array[i]; bachelor_degree[THIS_YEAR] += deptPtr->student_array.bachelor_degree[THIS_YEAR]; non_ug_bachelor_degree[THIS_YEAR] += deptPtr->student_array.non_ug_bachelor_degree[THIS_YEAR]; master_degree[THIS_YEAR] += deptPtr->student_array.master_degree[THIS_YEAR]; //0223 doctor_degree[THIS_YEAR] += deptPtr->student_array.doctor_degree[THIS_YEAR]; for (int y=0; y<DEGREE_TYPE_COUNT; y++) { time_to_degree[y][THIS_YEAR] += deptPtr->student_array.time_to_degree[y][THIS_YEAR]; dropout_rate[y][THIS_YEAR] += deptPtr->student_array.dropout_rate[y][THIS_YEAR]; } deptCount++; } //------------------------// for (int y=0; y<DEGREE_TYPE_COUNT; y++) time_to_degree[y][THIS_YEAR] /= deptCount; //--- special case handling: smooth the graph for bachelor Time to Degree ---// fake_disp_time_to_degree[BACHELOR_DEGREE][THIS_YEAR] = m.fmax( time_to_degree[BACHELOR_DEGREE][THIS_YEAR], math.get_random_snd(4.3f, 0.07f) ); //------------------------// GeneralDepartment* genDept = &department_res.general_dept; for (int y=0; y<DEGREE_TYPE_COUNT; y++) { dropout_rate[y][THIS_YEAR] += genDept->student_array.dropout_rate[y][THIS_YEAR]; } //990408 for (y=0; y<DEGREE_TYPE_COUNT; y++) //990408 dropout_rate[y][THIS_YEAR] /= deptCount + 1; }
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { DCAEncContext *c = avctx->priv_data; const int32_t *samples; int ret, i; if ((ret = ff_alloc_packet2(avctx, avpkt, c->frame_size, 0)) < 0) return ret; samples = (const int32_t *)frame->data[0]; subband_transform(c, samples); if (c->lfe_channel) lfe_downsample(c, samples); calc_masking(c, samples); find_peaks(c); assign_bits(c); calc_scales(c); quantize_all(c); shift_history(c, samples); init_put_bits(&c->pb, avpkt->data, avpkt->size); put_frame_header(c); put_primary_audio_header(c); for (i = 0; i < SUBFRAMES; i++) put_subframe(c, i); for (i = put_bits_count(&c->pb); i < 8*c->frame_size; i++) put_bits(&c->pb, 1, 0); flush_put_bits(&c->pb); avpkt->pts = frame->pts; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); avpkt->size = put_bits_count(&c->pb) >> 3; *got_packet_ptr = 1; return 0; }
//---------- Begin of function PlayerSchool::calc_student_performance -----------// //! void PlayerSchool::calc_student_performance() { shift_history(talent_academic, HISTORY_MONTH_COUNT); shift_history(talent_extracurricular, HISTORY_MONTH_COUNT); shift_history(talent_athletics, HISTORY_MONTH_COUNT); shift_history(satisfaction_academic, HISTORY_MONTH_COUNT); shift_history(satisfaction_student_life, HISTORY_MONTH_COUNT); shift_history(satisfaction_athletics, HISTORY_MONTH_COUNT); shift_history(satisfaction_overall, HISTORY_MONTH_COUNT); for (int d=0; d<DEGREE_TYPE_COUNT; d++) shift_history(talent_academic_all[d], HISTORY_MONTH_COUNT); shift_history(performance_academic_ug, HISTORY_MONTH_COUNT); StudentArray *stuPtr; const char AVG_VAR_COUNT = 11; float total[AVG_VAR_COUNT]; int i, totalStuCount = 0, totalUgtStuCount=0; int totalDoctorCount=0, totalMasterCount=0; memset(total, 0, sizeof(total)); for( i=department_array.size() ; i>0 ; i-- ) { if( department_array.is_deleted(i) ) continue; Department *dept = department_array[i]; stuPtr = &(department_array[i]->student_array); int stuCount = stuPtr->student_count; int ugtCount = dept->student_level_history[UG_TRADITION][THIS_YEAR]; //int ugAllCount = ugtCount + dept->student_level_history[UG_NONTRADITION][THIS_YEAR] + dept->student_level_history[DISTANCE_LEARN][THIS_YEAR]; int masCount = dept->student_level_history[MASTER][THIS_YEAR]; int docCount = dept->student_level_history[DOCTOR][THIS_YEAR]; // test[i] = ugtCount; // test1 = stuPtr->talent_academic[THIS_MONTH] * info.debug[i]; // test2++; total[0] += stuPtr->talent_academic[THIS_MONTH] * ugtCount; // total[0] += stuPtr->talent_academic[THIS_MONTH-1] * info.debug[i]; total[1] += stuPtr->talent_extracurricular[THIS_MONTH] * ugtCount; total[2] += stuPtr->talent_athletics[THIS_MONTH] * ugtCount; total[3] += stuPtr->satisfaction_academic[THIS_MONTH] * ugtCount; total[4] += stuPtr->satisfaction_student_life[THIS_MONTH] * ugtCount; total[5] += stuPtr->satisfaction_athletics[THIS_MONTH] * ugtCount; total[6] += stuPtr->satisfaction_overall[THIS_MONTH] * ugtCount; //ugAllCount; total[7] += stuPtr->performance_academic_ug[THIS_MONTH] * ugtCount; // ugAllCount; total[8] += stuPtr->talent_academic_all[BACHELOR_DEGREE][THIS_MONTH] * ugtCount; total[9] += stuPtr->talent_academic_all[MASTER_DEGREE][THIS_MONTH] * masCount; total[10] += stuPtr->talent_academic_all[DOCTOR_DEGREE][THIS_MONTH] * docCount; totalUgtStuCount += ugtCount; totalStuCount += stuCount; //totalUgAllCount += ugAllCount; totalMasterCount += masCount; totalDoctorCount += docCount; } // if (!totalStuCount ) // return; if ( totalUgtStuCount ) { //## 071299 chea 1.12.1 talent_academic[THIS_MONTH] = char(total[0] / totalUgtStuCount); // talent_academic[THIS_MONTH] = 33; //## 200199 chea 4 testing only // talent_academic[THIS_MONTH] = char(total[0] / info.debug[11]); talent_extracurricular [THIS_MONTH] = char(total[1] / totalUgtStuCount); talent_athletics [THIS_MONTH] = char(total[2] / totalUgtStuCount); satisfaction_academic [THIS_MONTH] = char(total[3] / totalUgtStuCount); satisfaction_student_life [THIS_MONTH] = char(total[4] / totalUgtStuCount); satisfaction_athletics [THIS_MONTH] = char(total[5] / totalUgtStuCount); satisfaction_overall [THIS_MONTH] = char(total[6] / totalUgtStuCount); //totalUgAllCount); talent_academic_all[BACHELOR_DEGREE][THIS_MONTH] = char(total[8] / totalUgtStuCount); performance_academic_ug[THIS_MONTH] = char(total[7] / totalUgtStuCount); } if ( totalMasterCount ) talent_academic_all[MASTER_DEGREE][THIS_MONTH] = char(total[9] / totalMasterCount); if ( totalDoctorCount ) talent_academic_all[DOCTOR_DEGREE][THIS_MONTH] = char(total[10] / totalDoctorCount); }
//---------- Begin of function StudentArray::calc_degree_awarded -----------// void StudentArray::calc_degree_awarded() { //-----------------------------------------// shift_history(bachelor_degree, HISTORY_YEAR_COUNT); shift_history(non_ug_bachelor_degree, HISTORY_YEAR_COUNT ); shift_history(master_degree, HISTORY_YEAR_COUNT); shift_history(doctor_degree, HISTORY_YEAR_COUNT); for (int y=0; y<DEGREE_TYPE_COUNT; y++) { shift_history(time_to_degree[y], HISTORY_YEAR_COUNT); shift_history(fake_disp_time_to_degree[y], HISTORY_YEAR_COUNT); shift_history(dropout_rate[y], HISTORY_YEAR_COUNT); } //-----------------------------------------// // // The [THIS_YEAR] element in all historical array // is always the latest obtainable value of the // variables. Some will have values for the // current year, some will have values for the // last year. So THIS_YEAR does not mean the // current year. // // As for the graduation rate, the value is // graduation rate of the last year as the value // for the current year hasn't been known yet. // //-----------------------------------------// bachelor_degree[THIS_YEAR] = cur_bachelor_degree; non_ug_bachelor_degree[THIS_YEAR] = cur_non_ug_bachelor_degree; master_degree [THIS_YEAR] = cur_master_degree; doctor_degree [THIS_YEAR] = cur_doctor_degree; //---- special handling: the first year, the master & doctor degrees are too low, artificially increase them ---// if( info.prerun_year && info.game_year == 1 ) { //--- count the number of master & doctor students in this department ---// int masterCount=0, doctorCount=0; for( int i=size() ; i>0 ; i-- ) { if( is_deleted(i) ) continue; Student* stuPtr = operator[](i); if( stuPtr->student_level == MASTER ) masterCount++; else if( stuPtr->student_level == DOCTOR ) doctorCount++; } // divided by the average # of years to get a degree master_degree[THIS_YEAR] = int( (float) masterCount / 1.6f); doctor_degree [THIS_YEAR] = doctorCount/5; } //---- see design note 0919 section 6 -----// time_to_degree[BACHELOR_DEGREE][THIS_YEAR] = math.safe_divide(time_to_degree_cumm[BACHELOR_DEGREE], cur_bachelor_degree); time_to_degree[MASTER_DEGREE][THIS_YEAR] = math.safe_divide(time_to_degree_cumm[MASTER_DEGREE], cur_master_degree); time_to_degree[DOCTOR_DEGREE][THIS_YEAR] = math.safe_divide(time_to_degree_cumm[DOCTOR_DEGREE], cur_doctor_degree); //--- special case handling: smooth the graph for bachelor Time to Degree ---// fake_disp_time_to_degree[BACHELOR_DEGREE][THIS_YEAR] = m.fmax( time_to_degree[BACHELOR_DEGREE][THIS_YEAR], math.get_random_snd(4.3f, 0.07f) ); //-----------------------------------------// int curSize[DEGREE_TYPE_COUNT]; // new student count this year const char degMap[MAX_STUDENT_LEVEL] = { BACHELOR_DEGREE, -1, MASTER_DEGREE, DOCTOR_DEGREE, -1}; memset(curSize,0,sizeof(curSize)); for (int i=size(); i>0; i--) { if ( is_deleted(i) ) continue; Student* stuPtr = operator[](i); // assume called after next_trimester and then enrollment if ( stuPtr->year_in_program == 1 ) { char deg = degMap[stuPtr->student_level]; if (deg >= 0) curSize[deg]++; } } const float lamda[] = { 0.775f, 0.1f, 0.8f }; for (int y=0; y<DEGREE_TYPE_COUNT; y++) { //990408 ave_entering_class[y] = math.latency_func(lamda[y], (float) curSize[y], ave_entering_class[y]); //990408 dropout_rate[y][THIS_YEAR] = math.safe_divide((float)cur_dropout[y], ave_entering_class[y]); dropout_rate[y][THIS_YEAR] = (float) cur_dropout[y]; } //-----------------------------------------// cur_bachelor_degree = 0; // reset it, it will be incremented as students graduate cur_non_ug_bachelor_degree = 0; cur_master_degree = 0; cur_doctor_degree = 0; for (int y=0; y<DEGREE_TYPE_COUNT; y++) { time_to_degree_cumm[y] = 0; cur_dropout[y] = 0; last_year_dropout[y]=0; last_year_dropout[y+1]=0; last_year_degree[y]=0; last_year_degree[y+1]=0; } ave_time_to_graduation_for_ug = 0; }
//---------- Begin of function StudentArray::calc_student_performance -----------// //! void StudentArray::calc_student_performance() { shift_history(talent_academic, HISTORY_MONTH_COUNT); shift_history(talent_extracurricular, HISTORY_MONTH_COUNT); shift_history(talent_athletics, HISTORY_MONTH_COUNT); shift_history(satisfaction_academic, HISTORY_MONTH_COUNT); shift_history(satisfaction_student_life, HISTORY_MONTH_COUNT); shift_history(satisfaction_athletics, HISTORY_MONTH_COUNT); shift_history(satisfaction_overall, HISTORY_MONTH_COUNT); for (int d=0; d<DEGREE_TYPE_COUNT; d++) shift_history(talent_academic_all[d], HISTORY_MONTH_COUNT); shift_history(performance_academic_ug, HISTORY_MONTH_COUNT); //-----------------// Student *stuPtr; const char AVG_VAR_COUNT = 11; int total[AVG_VAR_COUNT]; int i, ugtStuCount=0, ugAllCount=0, stuCount = 0, docCount=0, masCount=0; memset(total, 0, sizeof(total)); for( i=size() ; i>0 ; i-- ) { if( is_deleted(i) ) continue; stuPtr = operator[](i); if ( stuPtr->student_level == UG_TRADITION ) { total[0] += stuPtr->talent_academic; total[1] += stuPtr->talent_extracurricular; total[2] += stuPtr->talent_athletics; total[3] += stuPtr->satisfaction_academic; total[4] += stuPtr->satisfaction_student_life; total[5] += stuPtr->satisfaction_athletics; total[6] += stuPtr->satisfaction_overall; ugtStuCount++; } if ( (stuPtr->student_level) == UG_TRADITION ) { total[7] += (int) stuPtr->academic_achievement; total[8] += stuPtr->talent_academic; //ugtCount++; } else if ( stuPtr->student_level == MASTER ) { total[9] += stuPtr->talent_academic; masCount++; } else if ( stuPtr->student_level == DOCTOR ) { total[10] += stuPtr->talent_academic; docCount++; } stuCount++; } if (!stuCount) return; if ( ugtStuCount ) { //## 071299 chea 1.12.1 talent_academic[THIS_MONTH] = char(total[0] / ugtStuCount); talent_extracurricular [THIS_MONTH] = char(total[1] / ugtStuCount); talent_athletics [THIS_MONTH] = char(total[2] / ugtStuCount); satisfaction_academic [THIS_MONTH] = char(total[3] / ugtStuCount); satisfaction_student_life [THIS_MONTH] = char(total[4] / ugtStuCount); satisfaction_athletics [THIS_MONTH] = char(total[5] / ugtStuCount); satisfaction_overall [THIS_MONTH] = char(total[6] / ugtStuCount); // talent_academic[THIS_MONTH] = char(total[0] / stuCount); // talent_extracurricular [THIS_MONTH] = char(total[1] / stuCount); // talent_athletics [THIS_MONTH] = char(total[2] / stuCount); // satisfaction_academic [THIS_MONTH] = char(total[3] / stuCount); // satisfaction_student_life [THIS_MONTH] = char(total[4] / stuCount); // satisfaction_athletics [THIS_MONTH] = char(total[5] / stuCount); // satisfaction_overall [THIS_MONTH] = char(total[6] / stuCount); } if ( ugtStuCount ) { performance_academic_ug[THIS_MONTH] = char(total[7] / ugtStuCount); talent_academic_all[BACHELOR_DEGREE][THIS_MONTH] = char(total[8] / ugtStuCount); } if ( masCount ) talent_academic_all[MASTER_DEGREE][THIS_MONTH] = char(total[9] / masCount); if ( docCount ) talent_academic_all[DOCTOR_DEGREE][THIS_MONTH] = char(total[10] / docCount); /* talent_academic talent_extracurricular talent_athletics satisfaction_academic satisfaction_student_life satisfaction_athletics */ }
//----------- Begin of function Facility::update_parking --------// //! void Facility::update_parking(bool init) { //------------------// //990104 Parking and Crime model; see design response 0805. int demandVar[COEF_COUNT]; int totalDemand = 0; demandVar[0] = department_array.faculty_level_history[FACULTY_RANK_LEVEL_COUNT][THIS_YEAR]; demandVar[1] = int(finance.total_expense.staff / 65000000); for (int i=0; i<MAX_STUDENT_LEVEL; i++) demandVar[i+2] = department_array.student_level_history[i][THIS_YEAR]; for (int x=0; x<COEF_COUNT; x++) totalDemand += int(parking_demand_coef[player_school.campus_environment][x] * demandVar[x]); //------------------// if ( init ) { const float meanByEnvir[ENVIRONMENT_COUNT] = { 1.0f, 1.1f, 1.2f }; float mean = meanByEnvir[player_school.campus_environment]; // initialize as close-in supply cur_parking_supply = int(totalDemand * math.get_random_snd(mean, PSCH_SD(mean*0.1f))); projected_parking_supply = cur_parking_supply; farout_capacity = int(cur_parking_supply * math.get_random_snd(1.3f , PSCH_SD(0.1f))); } if ( !init && totalDemand > cur_parking_supply ) { if ( player_school.campus_environment == RURAL ) cur_parking_supply = totalDemand; // add far-out lots else if ( player_school.campus_environment == SUBURBAN && farout_capacity > 0 ) { int newSpace = min(farout_capacity, totalDemand - cur_parking_supply); farout_capacity -= newSpace; cur_parking_supply += newSpace; // add far-out lots } else { // build close-in structure // option 1: build structure instantly // 30: $30,000 per space finance.this_year.asset_array[AC_CAPITAL_RESERVE] -= 30 * (totalDemand - cur_parking_supply); projected_parking_supply = totalDemand; cur_parking_supply = projected_parking_supply; // option 2: use normal facilities construction procedure } } shift_history(parking_demand, HISTORY_YEAR_COUNT); shift_history(parking_supply, HISTORY_YEAR_COUNT); parking_demand[THIS_YEAR] = cur_parking_supply; parking_supply[THIS_YEAR] = totalDemand; if ( init ) { err_when(totalDemand <= 0); err_when(cur_parking_supply <= 0); for (int i = THIS_YEAR; i>=THIS_YEAR-1; i--) { parking_demand[i-1] = parking_demand[i]; parking_supply[i-1] = parking_supply[i]; } } }
//----------- Begin of function Facility::update_vars_monthly --------// //! void Facility::update_vars_monthly() { //----------------------// // update actual sf // (if new construction completed) //----------------------// DepartmentInfo *deptInfo; GeneralDepartment* dept; int deptCount = department_array.department_count; float normalOnm; int newSF, projectExpense, projectExpenseTotal = 0; // unit: square foot int totalActualSF = 0, totalNormalSF = 0, totalProjectedSF = 0; total_normal_onm = 0; //------ read in active department array -------// for( int i=0 ; i<=deptCount; i++ ) { if (i) { dept = (GeneralDepartment*) department_array[i]; deptInfo = (department_res.info_array+department_array[i]->department_id - 1); } else { // code to handle general deparment dept = &department_res.general_dept; deptInfo = &department_res.general_dept_info; } // check completed new construction // dept->next_month_construction(newSF, projectExpense); //Equals sf at the beginning of the prior year plus NEW CONSTRCUTION COMPLETED during the prior year. //This is the amount of space actually available for use during the year. deptInfo->actual_sf += newSF; projectExpenseTotal += projectExpense; // Same as actual_sf in that: this should be recalculated whenever new sf get completed. normalOnm = (deptInfo->actual_sf * deptInfo->normal_onm_cost / 1000.0f); total_normal_onm += (int) normalOnm; totalActualSF += deptInfo->actual_sf; totalNormalSF += deptInfo->normal_sf; totalProjectedSF += dept->get_constructing_sf() + deptInfo->actual_sf; err_when( deptInfo->normal_sf<=0 || deptInfo->actual_sf<=0 || normalOnm<=0 ); } // for screen "space usage": norm-projected-actual curves graph shift_history(normal_area, HISTORY_MONTH_COUNT); shift_history(actual_area, HISTORY_MONTH_COUNT); shift_history(projected_area, HISTORY_MONTH_COUNT); normal_area[THIS_MONTH] = totalNormalSF; actual_area[THIS_MONTH] = totalActualSF; projected_area[THIS_MONTH] = totalProjectedSF; //----------------------// // update backlog // //----------------------// // vars after the section "Beginning Space Inventory" // 990420 0.05f * int tmp = int(math.get_random_snd(0.0f, PSCH_SD(0.05f * float(total_normal_onm)) )); int beginBacklog = total_normal_onm + ( (tmp > 0) ? tmp : 0); // remove stage1_revenue, stage1_expense, stage2_expense float buget_monthly; { double cons1 = (1 + finance.inflation_rate/100.0 + finance.expense_policy_array[PL_STAFF_SALARY_INCREASES].result_value / 100.0); double cons2 = (1 + finance.inflation_rate/100.0 + finance.other_expense_growth/100.0); double computed_growthrate = finance.cost_rise_policy_array[AC_OPERATIONS_AND_MAINTENANCE].result_value; double base_value = cons1 * finance.expense_array[AC_OPERATIONS_AND_MAINTENANCE].staff + cons2 * finance.expense_array[AC_OPERATIONS_AND_MAINTENANCE].other; double change_value = base_value * computed_growthrate / 100.0; double new_value = (change_value + base_value ); buget_monthly = float(new_value / 12.0f); } cur_change_backlog = int( beginBacklog * escalation_factor_for_deferrd_maintenance_per_year / 12.0f - total_normal_onm / 12.0f - buget_monthly); // update end_backlog onm_n_backlog_history[SECOND_H_THIS_YEAR] = max(0, beginBacklog + cur_change_backlog); onm_n_backlog_history[SECOND_H_THIS_YEAR+1] = onm_n_backlog_history[SECOND_H_THIS_YEAR]; //------------------// update_history_sub(); }
//----------- Begin of function Facility::update_history_yearly ------// //! //! update time-series graphs for interface display //! void Facility::update_history_yearly() { int h; // part 2 // 1 of 2: shift history to "left" // for ( h=0; h<HISTORY_YEAR_COUNT-1; h++) { ratio_of_square_footage_to_benchmark[h] = ratio_of_square_footage_to_benchmark[h+1]; total_debt_capacity[h] = total_debt_capacity[h+1]; outstanding_debt_balance[h] = outstanding_debt_balance[h+1]; debt_limit[h] = debt_limit[h+1]; construction_project_spending[h] = construction_project_spending[h+1]; transfer_history[h] = transfer_history[h+1]; gifts_to_facility[h] = gifts_to_facility[h+1]; captial_reserve_expense[h] = captial_reserve_expense[h+1]; } shift_history(onm_n_backlog_history, HISTORY_YEAR_COUNT2); // 2 of 2: update current year values captial_reserve_expense[H_THIS_YEAR] = 0; // calc after RA // after 981016: float availableFunds = (float) finance.get_available_funds(); total_debt_capacity[THIS_YEAR] = (int) min( (float)(maximum_debt_balance_as_a_percent_of_funds_balances * availableFunds), (float)(finance.projected_total_operating_expense.this_year.total * max_interest_payments_as_a_percent_of_operating_expenditures / (finance.long_term_debt_interest / 100.0f)) );//min & max bug chea total_debt_capacity[THIS_YEAR] = max(0,total_debt_capacity[THIS_YEAR]); //--------------------------// // Ending Space Inventory // //--------------------------// float inflationRate = (float) finance.inflation_rate / 100.0f; const float growth = float(1 + inflationRate + finance.construction_cost_growth/100.0f); DepartmentInfo *deptInfo; GeneralDepartment* dept; int deptCount = department_array.department_count; int totalActualSF = 0, totalNormalSF = 0, totalProjectedSF = 0, i; for( i=0 ; i<=deptCount; i++ ) { if ( i ) { dept = (GeneralDepartment*) department_array[i]; // -1: otherwise will have bug deptInfo = (department_res.info_array + department_array[i]->department_id - 1); } else { // code to handle general deparment dept = &department_res.general_dept; deptInfo = &department_res.general_dept_info; } totalActualSF += deptInfo->actual_sf; totalNormalSF += deptInfo->normal_sf; totalProjectedSF += dept->get_constructing_sf() + deptInfo->actual_sf; // 1027; see response_func:Time_Variation float last1 = deptInfo->cost_growth; deptInfo->cost_growth = math.time_variation(last1, (deptInfo->cost_growth_last2), 1.4482f, -0.8011f, 0.003528950f) + 0.03f; deptInfo->cost_growth_last2 = last1; deptInfo->replacement_cost = int( deptInfo->replacement_cost * (1+inflationRate+deptInfo->cost_growth) ); err_when(deptInfo->replacement_cost <= 0); } // average the replacement_cost among the departments int totalReplacementCost=0; // Calculate the total Replacement Cost for( i=0 ; i<=deptCount; i++ ) { if ( i ) { // -1: otherwise will have bug deptInfo = (department_res.info_array + department_array[i]->department_id - 1); } else { // code to handle general deparment deptInfo = &department_res.general_dept_info; } totalReplacementCost += deptInfo->replacement_cost; } // get Average and store for( i=0 ; i<=deptCount; i++ ) { if ( i ) { // -1: otherwise will have bug deptInfo = (department_res.info_array + department_array[i]->department_id - 1); } else { // code to handle general deparment deptInfo = &department_res.general_dept_info; } deptInfo->replacement_cost = totalReplacementCost/deptCount; } // askbillok: is it what he want: // update this ratio after project completed //float ratioSF; ratio_of_square_footage_to_benchmark[THIS_YEAR] = 1.0f; err_when(!totalActualSF); for( i=0 ; i<=deptCount; i++ ) { if ( i ) { dept = (GeneralDepartment*) department_array[i]; deptInfo = (department_res.info_array+department_array[i]->department_id - 1); } else // code to handle general deparment deptInfo = &department_res.general_dept_info; float ratio_sf_to_benchmark = float(deptInfo->actual_sf) / deptInfo->normal_sf; ratio_of_square_footage_to_benchmark[THIS_YEAR] *= (float) math.safe_pow(ratio_sf_to_benchmark, float(deptInfo->actual_sf) / totalActualSF); } //-------- post last year data first -------// // finance.last_year.asset_array[AC_BUILDINGS] = finance.this_year.asset_array[AC_BUILDINGS]; // finance.last_year.asset_array[AC_CAPITAL_RESERVE] = finance.this_year.asset_array[AC_CAPITAL_RESERVE]; // finance.last_year.liability_array[AC_GENERAL_PLANT_DEBT] = finance.this_year.liability_array[AC_GENERAL_PLANT_DEBT]; //------------------------------------// // Year-end Replacement Cost and Debt // //------------------------------------// // assume called after finance optimization and finance.next_day()'s buget update// //askbill //option 1: update balance sheet yearly //update at the beginning of construction //finance.this_year.liability_array[AC_GENERAL_PLANT_DEBT] // = finance.last_year.liability_array[AC_GENERAL_PLANT_DEBT] // + total_actual_new_debt - finance.last_year.liability_array[AC_GENERAL_PLANT_DEBT] * finance.debt_fraction_repaid_annually / 100.0f; //option 2 // assume called after develop_office.next_day finance.this_year.asset_array[AC_BUILDINGS] // = E76 (year-end replacement cost = finance.this_year.asset_array[AC_BUILDINGS] - finance.this_year.asset_array[AC_BUILDINGS] / finance.building_life_for_calc_depreciation; finance.this_year.asset_array[AC_CAPITAL_RESERVE] += development_office.last_year.facilities; finance.this_year.liability_array[AC_GENERAL_PLANT_DEBT] = finance.this_year.liability_array[AC_GENERAL_PLANT_DEBT] - finance.this_year.liability_array[AC_GENERAL_PLANT_DEBT] * finance.debt_fraction_repaid_annually / 100.0f; facility_office.outstanding_debt_balance[THIS_YEAR] = finance.this_year.liability_array[AC_GENERAL_PLANT_DEBT]; finance.this_year.liability_array[AC_LIABILITY_TOTAL] = 0; for( i=0 ; i<LIABILITY_ITEM_COUNT-1 ; i++ ) { finance.this_year.liability_array[AC_LIABILITY_TOTAL] += finance.this_year.liability_array[i]; } //------------------------------------// // variables accumlated through a year construction_project_spending[THIS_YEAR] = 0; cur_change_backlog = 0; }
//---------- Begin of function Department::update_history -----------// //! //! update history arrays //! //! update_flag = UPDATE_TRIMESTER, UPDATE_MONTH, UPDATE_YEAR; (ooffice.h) //! void Department::update_history(char update_flag) { int i; switch (update_flag) { case UPDATE_MONTH: shift_history(p_faculty_research_history, HISTORY_MONTH_COUNT); shift_history(p_faculty_morale_history, HISTORY_MONTH_COUNT); calc_faculty_research(); calc_faculty_morale(); p_faculty_research_history[THIS_MONTH] = p_faculty_research; p_faculty_morale_history[THIS_MONTH] = p_faculty_morale; // special case calc_research_dollar(); calc_research_history(); // 1217 // must after calc_research_dollar() break; case UPDATE_TRIMESTER: shift_history(p_educational_quality_history, HISTORY_TRIMESTER_COUNT); shift_history(p_student_morale_history, HISTORY_TRIMESTER_COUNT); for (i=0; i<EDUCATIONAL_QUALITY_VAR_COUNT; i++) shift_history(var_educational_quality_history[i], HISTORY_TRIMESTER_COUNT); for (i=0; i<STUDENT_MORALE_VAR_COUNT; i++) shift_history(var_student_morale_history[i], HISTORY_TRIMESTER_COUNT); shift_history(p_tech_utilization_history, HISTORY_TRIMESTER_COUNT); calc_educational_quality(); calc_student_morale(); // must after calc_educational_quality calc_tech_utilization(); // special case don't have history p_educational_quality_history[THIS_TRIMESTER] = p_educational_quality; p_student_morale_history[THIS_TRIMESTER] = p_student_morale; p_tech_utilization_history[THIS_TRIMESTER] = p_tech_utilization; shift_history( distance_credits_provided_history, HISTORY_TRIMESTER_COUNT ); distance_credits_provided_history[THIS_TRIMESTER] = distance_credits_provided; break; case UPDATE_YEAR: for (i=0;i<FACULTY_RANK_LEVEL_COUNT_N_TOTAL; i++) shift_history(faculty_level_history[i], HISTORY_YEAR_COUNT); for (i=0;i<MAX_STUDENT_LEVEL_N_TOTAL; i++) shift_history(student_level_history[i], HISTORY_YEAR_COUNT); for (i=0;i<GENDER_ETHNIC_TYPE_COUNT_N_TOTAL; i++) { shift_history(faculty_gender_history[i], HISTORY_YEAR_COUNT); shift_history(student_gender_history[i], HISTORY_YEAR_COUNT); } calc_faculty_history(); calc_student_history(); //------// if( info.prerun_year==1 ) // only do this once during initialization. calc_research_norm(); //------// shift_history(p_academic_standing_history, HISTORY_YEAR_COUNT); shift_history(p_faculty_diversity_history, HISTORY_YEAR_COUNT); for (i=0; i<ACADEMIC_STANDING_VAR_COUNT; i++) shift_history(var_academic_standing_history[i], HISTORY_YEAR_COUNT); calc_academic_standing(); calc_faculty_diversity(); p_academic_standing_history[THIS_YEAR] = p_academic_standing; p_faculty_diversity_history[THIS_YEAR] = p_faculty_diversity; break; case UPDATE_ALL: update_history(UPDATE_MONTH); update_history(UPDATE_TRIMESTER); update_history(UPDATE_YEAR); // 0223; fix for interface bug for (i=THIS_MONTH-1; i>=THIS_MONTH-2; i--) { research_total_history[i] = research_total_history[THIS_MONTH]; research_direct_history[i] = research_direct_history[THIS_MONTH]; regular_faculty_with_research[i] = regular_faculty_with_research[THIS_MONTH]; } break; default: err_here(); break; } }
int vdehist_term_to_mgmt(struct vdehiststat *st) { unsigned char buf[BUFSIZE]; int n,i,rv=0; n=vdehist_termread(st->termfd,buf,BUFSIZE); //printf("termto mgmt N%d %x %x %x %x\n",n,buf[0],buf[1],buf[2],buf[3]); if (n==0) return 1; else if (n<0) return n; else { for (i=0;i<n && strlen(st->linebuf)<BUFSIZE;i++) { if (buf[i] == 0xff && buf[i+1] == 0xff) i++; if(buf[i]==0) buf[i]='\n'; /*telnet encode \n as a 0 when in raw mode*/ if (buf[i] == 0xff && buf[i+1] != 0xff) { i+=telnet_options(st,buf+i); } else if(buf[i] == 0x1b) { /* ESCAPE! */ if (buf[i+1]=='[' && st->status == HIST_COMMAND) { st->edited=1; switch (buf[i+2]) { case 'A': //fprintf(stderr,"UP\n"); erase_line(st,0); put_history(st); get_history(1,st); redraw_line(st,0); st->bufindex=strlen(st->linebuf); break; case 'B': //fprintf(stderr,"DOWN\n"); erase_line(st,0); put_history(st); get_history(-1,st); redraw_line(st,0); break; case 'C': //fprintf(stderr,"RIGHT\n"); if (st->linebuf[st->bufindex] != '\0') { vdehist_termwrite(st->termfd,"\033[C",3); (st->bufindex)++; } break; case 'D': //fprintf(stderr,"LEFT\n"); if (st->bufindex > 0) { vdehist_termwrite(st->termfd,"\033[D",3); (st->bufindex)--; } break; } i+=3; } else i+=2;/* ignored */ } else if(buf[i] < 0x20 && !(buf[i] == '\n' || buf[i] == '\r')) { /*ctrl*/ if (buf[i] == 4) /*ctrl D is a shortcut for UNIX people! */ { rv=1; break; } switch (buf[i]) { case 3: /*ctrl C cleans the current buffer */ erase_line(st,0); st->bufindex=0; st->linebuf[(st->bufindex)]=0; break; case 12: /* ctrl L redraw */ erase_line(st,1); redraw_line(st,1); break; case 1: /* ctrl A begin of line */ erase_line(st,0); st->bufindex=0; redraw_line(st,0); break; case 5: /* ctrl E endofline */ erase_line(st,0); st->bufindex=strlen(st->linebuf); redraw_line(st,0); case '\t': /* tab */ if (st->lastchar== '\t') { erase_line(st,1); showexpand(st->linebuf,st->bufindex,st->termfd); redraw_line(st,1); } else { erase_line(st,0); st->bufindex=tabexpand(st->linebuf,st->bufindex,BUFSIZE); redraw_line(st,0); } break; } } else if(buf[i] == 0x7f) { if(st->bufindex > 0) { char *x; (st->bufindex)--; x=st->linebuf+st->bufindex; memmove(x,x+1,strlen(x)); if (st->echo && !(st->status & HIST_PASSWDFLAG)) { if (st->edited) vdehist_termwrite(st->termfd,"\010\033[P",4); else vdehist_termwrite(st->termfd,"\010 \010",3); } } } else { if (st->echo && !(st->status & HIST_PASSWDFLAG)) { if (st->edited && buf[i] >= ' ') vdehist_termwrite(st->termfd,"\033[@",3); vdehist_termwrite(st->termfd,&(buf[i]),1); } if (buf[i] != '\r') { if (buf[i]=='\n') { if (st->status == HIST_COMMAND) { st->histindex=0; put_history(st); if (strlen(st->linebuf) > 0) shift_history(st); } st->bufindex=strlen(st->linebuf); if ((rv=hist_sendcmd(st)) != 0) break; st->bufindex=st->edited=st->histindex=0; st->linebuf[(st->bufindex)]=0; } else { char *x; x=st->linebuf+st->bufindex; memmove(x+1,x,strlen(x)+1); st->linebuf[(st->bufindex)++]=buf[i]; } } } st->lastchar=buf[i]; } } return rv; }