Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

Opschool.cpp Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Opschool.cpp

Go to the documentation of this file.
00001 //Filename    : OPSCHOOL.CPP
00002 //Description : School class
00003 //Owner       : Fred
00004 
00005 #include <OCONFIG.H>
00006 #include <OAUDIO.H>
00007 #include <OSYS.H>
00008 #include <OMATH.H>
00009 #include <OINFO.H>
00010 #include <ODATE.H>
00011 #include <OGAMESTR.H>
00012 #include <OMOUSECR.H>
00013 #include <OGAMESET.H>
00014 #include <OSCHLRES.H>
00015 #include <OSTUDENT.H>
00016 #include <ODEPT.H>
00017 #include <ODEPTRES.H>
00018 #include <OFACULTY.H>
00019 #include <OENROLL.H>
00020 #include <OFINANCE.H>
00021 #include <OCOURSE.H>
00022 #include <OATHLETI.H>
00023 #include <OPSCHOOL.H>
00024 #include <ONEWS.H>
00025 
00026 // ## begin chwg0408
00027 #if(GAME_VERSION>=200)
00028 enum {
00029     REPORT_TYPE_DEPARTMENT_PROFILE1, REPORT_TYPE_DEPARTMENT_PROFILE2,
00030     REPORT_TYPE_DEPARTMENT_ACTIVITIES, REPORT_TYPE_TURNOVER,
00031     REPORT_TYPE_INSTITUTION_PROFILE1, REPORT_TYPE_INSTITUTION_PROFILE2,
00032     REPORT_TYPE_INSTITUTION_ACTIVITIES, REPORT_TYPE_INSTITUTION_UNDERGRADUATE,
00033     REPORT_TYPE_FINANCE,
00034     REPORT_TYPE_RESIDENCE_HALL,
00035 };
00036 #else
00037 enum {
00038     REPORT_TYPE_DEPARTMENT_PROFILE1, REPORT_TYPE_DEPARTMENT_PROFILE2,
00039     REPORT_TYPE_DEPARTMENT_ACTIVITIES,
00040     REPORT_TYPE_INSTITUTION_PROFILE1, REPORT_TYPE_INSTITUTION_PROFILE2,
00041     REPORT_TYPE_INSTITUTION_ACTIVITIES, REPORT_TYPE_INSTITUTION_UNDERGRADUATE,
00042     REPORT_TYPE_FINANCE,
00043     REPORT_TYPE_RESIDENCE_HALL,
00044 };
00045 #endif
00046 enum { REPORT_MODE_INSTITUTION, REPORT_MODE_DEPARTMENT};
00047 enum {
00048     MODE_OVERALL=0,
00049     MODE_RANK=1,
00050     MODE_OUTPUTS=2,
00051     MODE_GENERAL_INSTITUTIONAL_PERFORMANCE=3,
00052     MODE_ATTITUDES_TOWARD_THE_INSTITUTION=4,
00053     MODE_FINANCE=5,
00054     MODE_MANAGEMENT=6,
00055     MODE_ADMISSION=7,
00056 };
00057 
00058 // ## end chwg0408
00059 
00060 //---------- Begin of function PlayerSchool::init -----------//
00062 void PlayerSchool::init() {
00063     memset( this, 0, sizeof(PlayerSchool) );
00064 
00065     //## chea 270999 make the student no. report update
00066     memset( ins_student_level_history,0,sizeof(ins_student_level_history));
00067 
00068     init_config();
00069     default_setting();
00070     // ## begin chwg0408
00071     current_score_report_type=MODE_OVERALL;
00072     current_report_type=REPORT_TYPE_INSTITUTION_PROFILE1;
00073     current_report_mode=REPORT_MODE_INSTITUTION;
00074 
00075     // ## end chwg0408
00076 }
00077 
00078 //---------- End of function PlayerSchool::init -----------//
00079 
00080 //---------- Begin of function PlayerSchool::deinit -----------//
00082 void PlayerSchool::deinit() {
00083     //student_array.deinit();
00084 }
00085 
00086 //---------- End of function PlayerSchool::deinit -----------//
00087 
00088 //---------- Begin of function PlayerSchool::init_config -----------//
00090 void PlayerSchool::init_config() {
00091     memset( this, 0, sizeof(PlayerSchool) );
00092 
00093     //------ initialize teaching_method_pref -----//
00094 
00095     teaching_method_pref[SEMINAR]           = 25;
00096     teaching_method_pref[DISTANCE_LEARN_COURSE] = 5;// class without breakout and class with breakout are classified as one group in selecting teaching method
00097     teaching_method_pref[CLASS_WITH_BREAKOUT]   = 30;
00098     teaching_method_pref[BREAKOUT_LAB]        = 0;
00099     teaching_method_pref[GENERAL]           = 40;
00100 
00101     //------ initialize course_match_order -------//
00102 
00103     course_match_order[0] = DOCTOR;
00104     course_match_order[1] = MASTER;
00105     course_match_order[2] = UG_TRADITION;
00106     course_match_order[3] = UG_NONTRADITION;
00107     course_match_order[4] = DISTANCE_LEARN;
00108 
00109     //------ initialize trimester -------//
00110     //##### begin fred 0805 #####//
00111     //BUGHERE0 the holidays among the trimesters may introduce semantic BUG
00112     // should define one more constant besides SUMMER,...
00113     //##### end fred 0805 #####//
00114 
00115     trimester_array[AUTUMN].start_month = 9;        // 1 Sep
00116     trimester_array[AUTUMN].start_day   = 1;
00117     trimester_array[AUTUMN].end_month   = 12;       // 26 Dec
00118     trimester_array[AUTUMN].end_day     = 26;
00119 
00120     trimester_array[WINTER].start_month = 1;        // 14 Jan
00121     trimester_array[WINTER].start_day   = 14;
00122     trimester_array[WINTER].end_month   = 5;        // 9 May
00123     trimester_array[WINTER].end_day     = 9;
00124 
00125     trimester_array[SUMMER].start_month = 5;        // 20 May
00126     trimester_array[SUMMER].start_day   = 20;
00127     trimester_array[SUMMER].end_month   = 8;        // 31 Aug
00128     trimester_array[SUMMER].end_day     = 30;       // game_day is limited to 1-30; see info.next_day()
00129 
00130     //--- calculate the total number of days in each trimester ---//
00131 
00132     trimester_array[AUTUMN].calc_total_days();
00133     trimester_array[WINTER].calc_total_days();
00134     trimester_array[SUMMER].calc_total_days();
00135 }
00136 
00137 //---------- End of function PlayerSchool::init_config -----------//
00138 
00139 //---------- Begin of function PlayerSchool::default_setting ----------//
00141 void PlayerSchool::default_setting() {
00142     cur_trimester=FIRST_TRIMESTER;
00143     //  new_trimester(AUTUMN);
00144 
00145     //--- for testing only, set to private research school ---//
00146 
00147     control      = PRIVATE;
00148     school_type = PRIVATE_SCHOOL;
00149 
00150     mascot = 1;                                     // not used yet
00151     while( player_school.is_hidden_mascot(player_school.mascot) ) {
00152         mascot++;
00153     }
00154 
00155     strcpy( school_name,       "Player University" );
00156     strcpy( player_first_name, "Player"     );
00157     strcpy( player_last_name,  "Name"     );
00158 
00159     scenario_id = 0;                                // not a scenario
00160 
00161     student_market = REGIONAL;
00162 
00163     location =  PACIFIC;
00164 
00165     prestige    = INPUT_MEDIUM;
00166     student_count = INPUT_MEDIUM;
00167     sl5_student_percent = INPUT_MEDIUM;
00168 
00169     parttime_undergrad_percent = INPUT_MEDIUM;
00170     ug_get_degree_in_5year_percent = INPUT_MEDIUM;
00171 
00172     fulltime_ug_in_housing_percent = INPUT_MEDIUM;
00173     athletic_program_intensity     = INPUT_MEDIUM;
00174 
00175     graduate_student_percent  = INPUT_MEDIUM;
00176     nondegree_student_percent = 30;
00177 
00178     doctoral_program_intensity    = INPUT_MEDIUM;
00179     sponsored_research_intensity  = INPUT_MEDIUM;   // ## useless parameter
00180 
00181     relative_wealth     = WEALTH_IN_BETWEEN;        //WEALTH_STRUGGLING,WEALTH_RICH
00182 
00183     control         = PRIVATE;
00184     campus_environment  = SUBURBAN;
00185 
00186     difficulty_multiplier = 1.0f;
00187 
00188     chance_event_frequency = INPUT_MEDIUM;          // INPUT_LOW, INPUT_MEDIUM
00189     chance_objective_frequency = INPUT_MEDIUM;
00190 #if(GAME_VERSION>=200)
00191     chance_perturbations = INPUT_MEDIUM;
00192     behavioral_response_speed = INPUT_LOW;          // INPUT_LOW=Normal,INPUT_MEDIUM=faster,INPUT_HIGH=light-speed
00193     threshold_event_flag = 1;
00194 #endif
00195 
00196     summer_emphasis = INPUT_LOW;
00197     summer_emphasis_last = INPUT_LOW;
00198     percent_summer_teaching_load = 0;
00199 
00200     err_when(INPUT_LOW != 0);
00201 
00202     calc_setting_vars();
00203 }
00204 
00205 //----------- End of function PlayerSchool::default_setting -----------//
00206 
00207 //---------- Begin of function PlayerSchool::init_setting_non_scenario ----------//
00209 void PlayerSchool::init_setting_non_scenario() {
00210     char pPrestige[]    = {                         //## chea 170899 larger range between med & high org. {1,5,10}
00211         1,3,10
00212     };
00213 
00214     //  char pDistanceL[]               = {0,10,30}; //## chea 0ringal idea
00215     char pDistanceL[]   = {                         //## chea 170999 I find out there are too much sl5 so I lower it.
00216         0,5,20
00217     };
00218 
00219     char pUgPt[]      = {0,20,50};
00220 
00221     //char pDegFiveYear[]       = {50,70,90};  //## chea org.
00222     char pDegFiveYear[] = {                         //## chea 130899 useed in oschlres.cpp ln 225
00223         50,70,100
00224     };
00225 
00226     char pUgInHousing[] = {30,60,90};
00227 
00228     char pGradStu[]   = {5,20,35};
00229     char docIntense[]   = {0,5,10};
00230     char researchIntense[]  = {                     //## chea the org. setting
00231         0,5,10
00232     };
00233 
00234     prestige        = pPrestige[prestige];
00235     sl5_student_percent = pDistanceL[sl5_student_percent];
00236     parttime_undergrad_percent = pUgPt[parttime_undergrad_percent];
00237     ug_get_degree_in_5year_percent = pDegFiveYear[ug_get_degree_in_5year_percent];
00238     fulltime_ug_in_housing_percent = pUgInHousing[fulltime_ug_in_housing_percent];
00239 
00240     graduate_student_percent    = pGradStu[graduate_student_percent];
00241     doctoral_program_intensity    = docIntense[doctoral_program_intensity];
00242     sponsored_research_intensity  = researchIntense[sponsored_research_intensity];
00243     /*
00244       //BUGHERE
00245       student_market = NATIONAL;
00246       prestige          = 8;
00247       student_count     = INPUT_MEDIUM;
00248       sl5_student_percent       = 1;
00249       parttime_undergrad_percent = 1;
00250       fulltime_ug_in_housing_percent = 60;
00251       athletic_program_intensity        = INPUT_MEDIUM;
00252       graduate_student_percent  = 30;
00253       doctoral_program_intensity = 7;
00254       sponsored_research_intensity =7;
00255       control = PRIVATE;
00256       campus_environment = SUBURBAN;    // (m.random(2) == 0)?URBAN:SUBURBAN;
00257     */
00258 }
00259 
00260 //----------- End of function PlayerSchool::init_setting_non_scenario -----------//
00261 
00262 //---------- Begin of function PlayerSchool::calc_setting_vars ----------//
00266 void PlayerSchool::calc_setting_vars() {
00267     //----- set percent_student_in_state -----//
00268 
00269     switch(student_market) {
00270     case NATIONAL:
00271         percent_student_in_state = 30;
00272         break;
00273 
00274     case REGIONAL:
00275         percent_student_in_state = 50;
00276         break;
00277 
00278     case LOCAL:
00279         percent_student_in_state = 70;
00280         break;
00281     }
00282 
00283     //----- set relative_wealth_value -------//
00284 
00285     switch(relative_wealth) {
00286     case WEALTH_RICH:
00287         relative_wealth_value = 2;                  // if we set it to 3, for some unknown reasons, we will get very low sponsored research amounts for all departments.
00288         break;
00289 
00290     case WEALTH_IN_BETWEEN:
00291         relative_wealth_value = 2;
00292         break;
00293 
00294     case WEALTH_STRUGGLING:
00295         relative_wealth_value = 1;
00296         break;
00297     }
00298 }
00299 
00300 //----------- End of function PlayerSchool::calc_setting_vars -----------//
00301 
00302 //---------- Begin of function PlayerSchool::next_day ----------//
00304 void PlayerSchool::next_day() {
00305 
00306     //--- if now it is at the end of a trimester, close the current trimester and open a new trimester ---//
00307 
00308     if( trimester_array[cur_trimester].end_month == info.game_month &&
00309         trimester_array[cur_trimester].end_day == info.game_day ) {
00310         is_trimester_off  = 1;                        // it is now in a trimester break
00311         trimester_off_day = 1;                        // the nth day since the trimester is off
00312 
00313         //--- if the current trimester is the last trimester, proceeds to the first trimester in the new school year ---//
00314 
00315         if( ++cur_trimester >= TRIMESTER_PER_YEAR ) {
00316             cur_trimester = 0;
00317         }
00318 
00319         new_trimester(cur_trimester);
00320 
00321         // new_trimester() above includes graduate() and dropout()
00322 
00323         enroll_res.calc_student_count();
00324 
00325         // faculty hiring can be added here
00326 
00327         //---------------------------------------//
00328     }
00329 
00330     //------- if the trimester is off -------//
00331 
00332     if( is_trimester_off ) {
00333         //--- the trimester break ends when the time reaches the beginning of the new trimester ---//
00334 
00335         if( trimester_array[cur_trimester].start_month == info.game_month &&
00336             trimester_array[cur_trimester].start_day == info.game_day ) {
00337             is_trimester_off = 0;
00338             //#### begin fred 0911 ####//
00339             info.graph_trimester_passed = min(info.graph_trimester_passed+1, HISTORY_TRIMESTER_COUNT);
00340             //#### begin fred 0915 ####//
00341             info.graph_trimester = min(info.graph_trimester+1, HISTORY_TRIMESTER_COUNT);
00342         }
00343         else {
00344             trimester_off_day++;                        // for various function's uses like student selecting courses.
00345         }
00346     }
00347 }
00348 
00349 //----------- End of function PlayerSchool::next_day -----------//
00350 
00351 //---------- Begin of function PlayerSchool::new_trimester ----------//
00353 void PlayerSchool::new_trimester(int trimesterId) {
00354     int oldCursor = mouse_cursor.get_icon();
00355 
00356     mouse_cursor.set_icon(CURSOR_WAITING);
00357 
00358     //------------------------------------//
00359 
00360     cur_trimester = trimesterId;
00361 
00362     cur_trimester_start_date = date.julian( info.game_year,
00363                                             trimester_array[cur_trimester].start_month,
00364                                             trimester_array[cur_trimester].start_day );
00365 
00366     //----- call next_trimester() of other classes -----//
00367     //#### begin fred 0922 ####//
00368     next_trimester();                               // recalc adjusted_student_major_pref for change major
00369     //#### end fred 0922 ####//
00370 
00371     department_array.calc_course_pref();            // for select course
00372 
00373     sys.yield();
00374 
00375     for( int i=department_array.size() ; i>0 ; i--) {
00376         if( department_array.is_deleted(i) )
00377             continue;
00378 
00379         Department* deptPtr = department_array[i];
00380 
00381         deptPtr->faculty_array.next_trimester();      // will think_departure, promotion
00382 
00383         sys.yield();
00384 
00385         deptPtr->student_array.next_trimester();      // will think_graduate, dropout
00386 
00387         sys.yield();
00388     }
00389 
00390     department_res.general_dept.student_array.next_trimester();
00391 
00392     sys.yield();
00393 
00394     mouse_cursor.restore_icon(oldCursor);
00395 
00396     //------ the start of a new academic year -------//
00397 
00398     if( cur_trimester == FIRST_TRIMESTER )          // RESOURCE ALLOCATION HERE!
00399         finance.new_fiscal_year();                    // assume called after faculty departure
00400     // and graduation, dropout
00401 
00402     //---------------------------------------//
00403 
00404 }
00405 
00406 //----------- End of function PlayerSchool::new_trimester -----------//
00407 
00408 //---------- Begin of function PlayerSchool::trimester_str ----------//
00410 char* PlayerSchool::trimester_str() {
00411     static String str;
00412 
00413     str  = game_str_res.trimester_str(cur_trimester);
00414     str += " \'";
00415 #if(GAME_VERSION>=200)
00416     str += info.financial_year();
00417 #else
00418     str += info.game_year;
00419 #endif
00420 
00421     return str;
00422 }
00423 
00424 //----------- End of function PlayerSchool::trimester_str -----------//
00425 
00426 //---------- Begin of function Trimester::calc_total_days ----------//
00428 void Trimester::calc_total_days() {
00429     int startDate = date.julian( 1990, start_month, start_day );
00430     int endDate;
00431 
00432     if( end_month > start_month )                   // in the same year
00433         endDate = date.julian( 1990, end_month, end_day );
00434     else
00435         // in the next year
00436         endDate = date.julian( 1991, end_month, end_day );
00437 
00438     total_days = endDate - startDate + 1;
00439 }
00440 
00441 //----------- End of function Trimester::calc_total_days -----------//
00442 
00443 //## chea 270999 for update stu_sum only
00444 //---------- Begin of function PlayerSchool::update_stu_sum ----------//
00446 void PlayerSchool::update_stu_sum() {
00447     int i,j,k,l,m;
00448     int test_course_count=0;
00449     int stdnotest1 = 0;                             //## chea 270899
00450     int stdnotest2 = 0;                             //## chea 270899
00451     int underno = 0;
00452     int nontrno =0;
00453     int masterno = 0;
00454     int docno =0;
00455     int dlno =0;
00456     int is_gen_dept =0;
00457     int not_h_course = 0;
00458     int not_h_course1 = 0;
00459     int not_h_course2 = 0;
00460     int not_h_course3 = 0;
00461     int coures_less_40 =0 ;
00462     int coures_less_41 =0 ;
00463     int coures_less_42 =0 ;
00464     int coures_less_43 =0 ;
00465     int coures_less_44 =0 ;
00466     int count = 0;
00467 
00468     StudentArray* stuArr;
00469     Student *stuPtr;
00470     Department*  cur_dept_ptr;
00471 
00472     //reset all variable
00473     // zero it out
00474     memset(ins_student_level_no, 0, sizeof(ins_student_level_no));
00475 
00476     for ( l=department_array.size(); l>=0; l-- ) {
00477         if (l) {
00478             if ( department_array.is_deleted(l) )
00479                 continue;
00480             cur_dept_ptr = department_array[l];
00481 
00482             for(m=0; m<MAX_STUDENT_LEVEL+1; m++) {
00483                 cur_dept_ptr->dept_student_level_no[m] = 0;
00484                 if(info.prerun_year == 1 && info.game_month == 9 && info.game_day == 1) {
00485                     for(int b=0; b<HISTORY_TRIMESTER_COUNT; b++)
00486                         cur_dept_ptr->dept_student_level_history[m][b] = 0;
00487                 }
00488             }
00489         }
00490         else {
00491             for(m=0; m<MAX_STUDENT_LEVEL+1; m++)
00492                 department_res.general_dept.dept_student_level_no[m] = 0;
00493         }
00494     }
00495 
00496     //dept_student_level_no
00497     err_when( department_array.size() == 0 );
00498     for ( i=department_array.size(); i>=0; i-- ) {
00499         is_gen_dept =0;
00500         if (i) {
00501             if ( department_array.is_deleted(i) )
00502                 continue;
00503             stuArr = &(department_array[i]->student_array);
00504             cur_dept_ptr = department_array[i];
00505 
00506         }
00507         else {
00508             stuArr = &(department_res.general_dept.student_array);
00509             is_gen_dept =1;
00510         }
00511         // loop student
00512 
00513         for (j=stuArr->size(); j>0; j--) {
00514             if ( stuArr->is_deleted(j) )
00515                 continue;
00516             stdnotest1++;
00517             sys.yield();
00518             stuPtr = stuArr->operator[](j);
00519 
00520             // student_level{ UG_TRADITION, UG_NONTRADITION, MASTER, DOCTOR, DISTANCE_LEARN }
00521             if(stuPtr->student_level == UG_TRADITION) {
00522                 if(is_gen_dept == 0) {
00523                     underno++;
00524                     cur_dept_ptr->dept_student_level_no[UG_TRADITION]++;
00525                 }
00526                 else
00527                     department_res.general_dept.dept_student_level_no[UG_TRADITION]++;
00528             }
00529             else if(stuPtr->student_level == UG_NONTRADITION) {
00530                 if(is_gen_dept == 0) {
00531                     nontrno++;
00532                     cur_dept_ptr->dept_student_level_no[UG_NONTRADITION]++;
00533                 }
00534                 else
00535                     department_res.general_dept.dept_student_level_no[UG_NONTRADITION]++;
00536             }
00537             else if(stuPtr->student_level == MASTER) {
00538                 if(is_gen_dept == 0) {
00539                     masterno++;
00540                     cur_dept_ptr->dept_student_level_no[MASTER]++;
00541                 }
00542                 else
00543                     department_res.general_dept.dept_student_level_no[MASTER]++;
00544             }
00545             else if(stuPtr->student_level == DOCTOR) {
00546                 if(is_gen_dept == 0) {
00547                     docno++;
00548                     cur_dept_ptr->dept_student_level_no[DOCTOR]++;
00549                 }
00550                 else
00551                     department_res.general_dept.dept_student_level_no[DOCTOR]++;
00552             }
00553             else if(stuPtr->student_level == DISTANCE_LEARN) {
00554                 if(is_gen_dept == 0) {
00555                     dlno++;
00556                     cur_dept_ptr->dept_student_level_no[DISTANCE_LEARN]++;
00557                 }
00558                 else
00559                     department_res.general_dept.dept_student_level_no[DISTANCE_LEARN]++;
00560             }
00561 
00562         }                                             // end for j
00563 
00564         // fix in version 2
00565         if(is_gen_dept == 0) {
00566             for(k=0; k<MAX_STUDENT_LEVEL; k++)
00567                 cur_dept_ptr->dept_student_level_no[MAX_STUDENT_LEVEL] += cur_dept_ptr->dept_student_level_no[k];
00568         }
00569         else {
00570             for(k=0; k<MAX_STUDENT_LEVEL; k++)
00571                 department_res.general_dept.dept_student_level_no[MAX_STUDENT_LEVEL] += department_res.general_dept.dept_student_level_no[k];
00572         }
00573 
00574     }
00575 
00576     ins_student_level_no[UG_TRADITION] = underno;
00577     ins_student_level_no[UG_NONTRADITION] = nontrno;
00578     ins_student_level_no[MASTER] = masterno;
00579     ins_student_level_no[DOCTOR] = docno;
00580     ins_student_level_no[DISTANCE_LEARN] = dlno;
00581     ins_student_level_no[MAX_STUDENT_LEVEL] = underno + nontrno + masterno +docno +dlno;
00582 
00583     for(k=0; k<MAX_STUDENT_LEVEL+1; k++)
00584         player_school.ins_student_level_history[k][HISTORY_TRIMESTER_COUNT-1] = ins_student_level_no[k];
00585 
00586     //## chea 300999 create a history for those graphs in student no. report
00587     for ( i=department_array.size(); i>=0; i-- ) {
00588         if ( department_array.is_deleted(i) )
00589             continue;
00590         cur_dept_ptr = department_array[i];
00591         //shift history
00592         for(int count1=0;count1<MAX_STUDENT_LEVEL_N_TOTAL;count1++)
00593             shift_history(cur_dept_ptr->dept_student_level_history[count1], HISTORY_TRIMESTER_COUNT);
00594 
00595         //-- department wide --//
00596         for(int count=0;count<MAX_STUDENT_LEVEL_N_TOTAL;count++) {
00597             cur_dept_ptr->dept_student_level_history[count][HISTORY_TRIMESTER_COUNT-1] = cur_dept_ptr->dept_student_level_no[count];
00598         }
00599     }
00600 
00601 }
00602 
00603 //----------- End of function PlayerSchool::update_stu_sum -----------//
00604 
00605 //## chea 290999 for update stu_sum only
00606 //---------- Begin of function PlayerSchool::update_gender ----------//
00608 void PlayerSchool::update_gender() {
00609     int i,j,k,l,m;
00610 
00611     int gender1 = 0;
00612     int gender2 = 0;
00613     int gender3 = 0;
00614     int gender4 = 0;
00615 
00616     int is_gen_dept = 0;
00617     int not_h_course = 0;
00618     int not_h_course1 = 0;
00619     int not_h_course2 = 0;
00620     int not_h_course3 = 0;
00621     int coures_less_40 = 0 ;
00622     int coures_less_41 = 0 ;
00623     int coures_less_42 = 0 ;
00624     int coures_less_43 = 0 ;
00625     int coures_less_44 = 0 ;
00626     int count = 0;
00627 
00628     StudentArray* stuArr;
00629     Student *stuPtr;
00630     Department*  cur_dept_ptr;
00631 
00632     //reset all variable
00633     // zero it out
00634     memset(ins_gender_student_level_no, 0, sizeof(ins_gender_student_level_no));
00635 
00636     for ( l=department_array.size(); l>=0; l-- ) {
00637         if (l) {
00638             if ( department_array.is_deleted(l) )
00639                 continue;
00640             cur_dept_ptr = department_array[l];
00641 
00642             for(m=0; m<GENDER_ETHNIC_TYPE_COUNT_N_TOTAL; m++) {
00643                 cur_dept_ptr->dept_gender_student_level_no[m] = 0;
00644                 if(info.prerun_year == 1 && info.game_month == 9 && info.game_day == 1) {
00645                     for(int b=0; b<HISTORY_TRIMESTER_COUNT; b++)
00646                         cur_dept_ptr->dept_gender_student_level_history[m][b] = 0;
00647                 }
00648             }
00649         }
00650         else {
00651             for(m=0; m<GENDER_ETHNIC_TYPE_COUNT_N_TOTAL; m++)
00652                 department_res.general_dept.dept_gender_student_level_no[m] = 0;
00653         }
00654     }
00655 
00656     //dept_gender_student_level_no
00657     err_when( department_array.size() == 0 );
00658     for ( i=department_array.size(); i>=0; i-- ) {
00659         is_gen_dept =0;
00660         if (i) {
00661             if ( department_array.is_deleted(i) )
00662                 continue;
00663             stuArr = &(department_array[i]->student_array);
00664             cur_dept_ptr = department_array[i];
00665 
00666         }
00667         else {
00668             stuArr = &(department_res.general_dept.student_array);
00669             is_gen_dept =1;
00670         }
00671         // loop student
00672 
00673         for (j=stuArr->size(); j>0; j--) {
00674             if ( stuArr->is_deleted(j) )
00675                 continue;
00676 
00677             sys.yield();
00678             stuPtr = stuArr->operator[](j);
00679 
00680 #if(GAME_VERSION>=200)
00681             if ( stuPtr->student_level == DISTANCE_LEARN )
00682                 continue;
00683 #endif
00684 
00685             // gender_level  { NONMINORITY_MALE, NONMINORITY_FEMALE, MINORITY_MALE, MINORITY_FEMALE };
00686             if(stuPtr->gender_ethnic_group == NONMINORITY_MALE) {
00687                 if(is_gen_dept == 0) {
00688                     gender1++;
00689                     cur_dept_ptr->dept_gender_student_level_no[NONMINORITY_MALE]++;
00690                 }
00691                 else
00692                     department_res.general_dept.dept_gender_student_level_no[NONMINORITY_MALE]++;
00693             }
00694             else if(stuPtr->gender_ethnic_group == NONMINORITY_FEMALE) {
00695                 if(is_gen_dept == 0) {
00696                     gender2++;
00697                     cur_dept_ptr->dept_gender_student_level_no[NONMINORITY_FEMALE]++;
00698                 }
00699                 else
00700                     department_res.general_dept.dept_gender_student_level_no[NONMINORITY_FEMALE]++;
00701             }
00702             else if(stuPtr->gender_ethnic_group == MINORITY_MALE) {
00703                 if(is_gen_dept == 0) {
00704                     gender3++;
00705                     cur_dept_ptr->dept_gender_student_level_no[MINORITY_MALE]++;
00706                 }
00707                 else
00708                     department_res.general_dept.dept_gender_student_level_no[MINORITY_MALE]++;
00709             }
00710             else if(stuPtr->gender_ethnic_group == MINORITY_FEMALE) {
00711                 if(is_gen_dept == 0) {
00712                     gender4++;
00713                     cur_dept_ptr->dept_gender_student_level_no[MINORITY_FEMALE]++;
00714                 }
00715                 else
00716                     department_res.general_dept.dept_gender_student_level_no[MINORITY_FEMALE]++;
00717             }
00718 
00719         }                                             // end for j
00720 
00721         for(k=0; k<GENDER_ETHNIC_TYPE_COUNT_N_TOTAL-1; k++)
00722             cur_dept_ptr->dept_gender_student_level_no[GENDER_ETHNIC_TYPE_COUNT_N_TOTAL-1] += cur_dept_ptr->dept_gender_student_level_no[k];
00723     }
00724 
00725     //I add the general department student as well
00726     ins_gender_student_level_no[NONMINORITY_MALE] = gender1 + department_res.general_dept.dept_gender_student_level_no[NONMINORITY_MALE];
00727     ins_gender_student_level_no[NONMINORITY_FEMALE] = gender2+ department_res.general_dept.dept_gender_student_level_no[NONMINORITY_FEMALE];
00728     ins_gender_student_level_no[MINORITY_MALE] = gender3+ department_res.general_dept.dept_gender_student_level_no[MINORITY_MALE];
00729     ins_gender_student_level_no[MINORITY_FEMALE] = gender4+ department_res.general_dept.dept_gender_student_level_no[MINORITY_FEMALE];
00730     ins_gender_student_level_no[GENDER_ETHNIC_TYPE_COUNT] = gender1+gender2+gender3+gender4;
00731 
00732     for(k=0; k<GENDER_ETHNIC_TYPE_COUNT_N_TOTAL; k++)
00733         player_school.ins_gender_student_level_history[k][HISTORY_TRIMESTER_COUNT-1] = ins_gender_student_level_no[k];
00734 
00735     //## chea 300999 create a history for those graphs in student no. report
00736     for ( i=department_array.size(); i>=0; i-- ) {
00737         if ( department_array.is_deleted(i) )
00738             continue;
00739         cur_dept_ptr = department_array[i];
00740         //shift history
00741         for(int count1=0;count1<GENDER_ETHNIC_TYPE_COUNT_N_TOTAL;count1++)
00742             shift_history(cur_dept_ptr->dept_gender_student_level_history[count1], HISTORY_TRIMESTER_COUNT);
00743 
00744         //-- department wide --//
00745         for(int count=0;count<GENDER_ETHNIC_TYPE_COUNT_N_TOTAL;count++) {
00746             cur_dept_ptr->dept_gender_student_level_history[count][HISTORY_TRIMESTER_COUNT-1] = cur_dept_ptr->dept_gender_student_level_no[count];
00747         }
00748     }
00749 
00750 }
00751 
00752 //----------- End of function PlayerSchool::update_gender -----------//
00753 
00754 //----------- Begin of function PlayerSchool::latency_func -----------//
00758 float PlayerSchool::latency_func(float latencyPara, float curValue, float inputValue) {
00759 #if(GAME_VERSION>=200)
00760     if(behavioral_response_speed==INPUT_MEDIUM)     // faster
00761         // may be similar to gamma function
00762         return math.latency_func(latencyPara*0.5f, curValue, inputValue);
00763     else if(behavioral_response_speed==INPUT_HIGH)  // light-speed
00764         // or 1.0f or just return inputValue?
00765         return math.latency_func(0.0f, curValue, inputValue);
00766     else
00767         // INPUT_LOW
00768         return math.latency_func(latencyPara, curValue, inputValue);
00769 #else
00770     return math.latency_func(latencyPara, curValue, inputValue);
00771 #endif
00772 }
00773 
00774 //----------- End of function PlayerSchool::latency_func -----------//
00775 
00776 //----------- Begin of function PlayerSchool::is_hidden_mascot -----------//
00780 int PlayerSchool::is_hidden_mascot(int mascotId) {
00781 #if(GAME_VERSION>=200)
00782     if( mascot==5 )                                 // hide indian mascot in version 2
00783         return 1;
00784 #endif
00785     return 0;
00786 }
00787 
00788 //----------- End of function PlayerSchool::is_hidden_mascot -----------//

Generated on Fri Aug 23 01:38:16 2002 for VirtualU by doxygen1.2.17