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

Password:

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

Odeptgen.cpp

Go to the documentation of this file.
00001 //Filename    : ODEPT.H
00002 //Description : Department Class Definition
00003 //Owner       : Fred
00004 
00005 #include <ALL.H>
00006 #include <ODEPT.H>
00007 #include <ODEPTRES.H>
00008 #include <ODEPTGEN.H>
00009 
00010 //----------- Begin of function GeneralDepartment Constructor -----//
00012 GeneralDepartment::GeneralDepartment() {
00013     init();
00014 }
00015 
00016 //------------- End of function GeneralDepartment Constructor -----//
00017 
00018 //----------- Begin of function GeneralDepartment init -----//
00020 void GeneralDepartment::init() {
00021     //don't do this!!!: memset(this, 0, sizeof(GeneralDepartment));
00022     err_when(student_array.student_count != 0);
00023     // fix in version 2
00024     student_array.zap();                            // clear empty_room_array in last game
00025 
00026     //
00027     department_id = 0;
00028 
00029     //
00030     memset(project_array, 0, sizeof(project_array));
00031     project_count = 0;
00032     project_added_this_year = false;
00033 
00034 }
00035 
00036 //------------- End of function GeneralDepartment init -----//
00037 
00038 //----------- Begin of function GeneralDepartment next_day -----//
00040 void GeneralDepartment::next_day() {
00041     student_array.next_day();
00042 }
00043 
00044 //------------- End of function GeneralDepartment next_day -----//
00045 
00046 //----------- Begin of function GeneralDepartment next_month_construction -----//
00051 void GeneralDepartment::next_month_construction(int &newSF, int &expense) {
00052     newSF = 0;
00053     expense = 0;
00054 
00055     for( int i=project_count-1 ; i>=0 ; i-- ) {
00056         if( --(project_array[i].month_left) <= 0 ) {
00057             newSF += project_array[i].new_sf;
00058             expense += project_array[i].expense;
00059 
00060             m.del_array_rec(project_array, project_count, sizeof(project_array[0]), i+1 );
00061             project_count--;
00062         }
00063     }
00064 }
00065 
00066 //------------- End of function GeneralDepartment next_month_construction -----//
00067 
00068 //----------- Begin of function GeneralDepartment:add_construction -----//
00077 void GeneralDepartment::add_construction(int newSF, int expense) {
00078     err_when( newSF <= 0 || expense <=0 );
00079 
00080     project_array[project_count].new_sf  = newSF;
00081     project_array[project_count].expense = expense;
00082 
00083 #if(GAME_VERSION>=200)
00084     project_array[project_count].month_left = 12;
00085 #else
00086     if ( !project_added_this_year )
00087         project_array[project_count].month_left = department_res[department_id]->months_to_construct;
00088     else
00089         project_array[project_count].month_left = 0;
00090 #endif
00091 
00092     project_count++;
00093     err_when(project_count > MAX_PROJECT_COUNT);
00094 
00095     project_added_this_year = true;
00096 }
00097 
00098 //------------- End of function GeneralDepartment:add_construction -----//
00099 
00100 //----------- Begin of function GeneralDepartment:next_month_construction -----//
00104 void GeneralDepartment::confirm_construction_yearly() {
00105     //TO sort project_array by month_left (incrementaly)
00106     // IF genDeptInfo->months_to_construct will change
00107 
00108     // project_added_this_year = false;
00109 }
00110 
00111 //------------- End of function GeneralDepartment:next_month_construction -----//
00112 
00113 //----------- Begin of function GeneralDepartment:next_month_construction -----//
00115 int GeneralDepartment::get_constructing_sf() {
00116     int total = 0;
00117 
00118     for ( int i=0; i<project_count; i++) {
00119         total += project_array[i].new_sf;
00120     }
00121 
00122     return total;
00123 }
00124 
00125 //------------- End of function GeneralDepartment:next_month_construction -----//
00126 
00127 //----- Begin of function GeneralDepartment::get_course_requirement ----//
00136 int GeneralDepartment::get_course_requirement(int studentLevel, int targetDeptRecno, int courseDepth) {
00137     DepartmentInfo* thisDeptInfo = department_res[department_id];
00138 
00139     int targetDeptId  = department_array[targetDeptRecno]->department_id;
00140 
00141     //## chea 291199 added to fix 2.1.1
00142     int targetFieldId=0;
00143 
00144     if( targetDeptId > 0 )
00145         targetFieldId = department_res[targetDeptId]->field_id;
00146 
00147     if( targetDeptId == department_id )             // if the target department is this departemnt, set targetFieldId to 0, as 0 means own department
00148         targetFieldId = 0;
00149 
00150     //-- if targetDeptId is 0, the first element in the depth array will be used. for instance, bachelor_depth1[0] will be used if the department is a general education department
00151 
00152     switch( studentLevel ) {
00153     case UG_TRADITION:
00154     case UG_NONTRADITION:
00155     case DISTANCE_LEARN: {
00156         switch(courseDepth) {
00157         case DEPTH_D1:
00158             // [0] is own department
00159             return thisDeptInfo->bachelor_depth1[targetFieldId];
00160 
00161         case DEPTH_D2:
00162             return thisDeptInfo->bachelor_depth2[targetFieldId];
00163 
00164         case DEPTH_D3:
00165             return thisDeptInfo->bachelor_depth3[targetFieldId];
00166         }
00167         break;
00168     }
00169 
00170     case MASTER: {
00171         switch(courseDepth) {
00172         case DEPTH_D3:
00173             return thisDeptInfo->master_depth3[targetFieldId];
00174 
00175         case DEPTH_GR:
00176             return thisDeptInfo->master_graduate[targetFieldId];
00177         }
00178         break;
00179     }
00180 
00181     case DOCTOR:
00182         return thisDeptInfo->doctor_graduate[targetFieldId];
00183         break;
00184     }
00185 
00186     err_here();
00187     return 0;
00188 }
00189 
00190 //------ End of function GeneralDepartment::get_course_requirement -----//

Generated on Fri Aug 23 01:37:24 2002 for VirtualU by doxygen1.2.17