00001
00002
00003
00004
00005 #include <OBATTLE.H>
00006 #include <OMUSIC.H>
00007 #include <OBOX.H>
00008 #include <OGAME.H>
00009 #include <OINFO.H>
00010 #include <OMISC.H>
00011 #include <OMOUSE.H>
00012 #include <OMOUSECR.H>
00013 #include <OSCHLRES.H>
00014 #include <ODEPT.H>
00015 #include <OSYS.H>
00016 #include <OWORLD.H>
00017 #include <ORECT.h>
00018 #include <OFIRM.H>
00019 #include <OROAD.H>
00020 #include <OPLANT.H>
00021 #include <OFIRMRES.H>
00022 #include <OLETTER.H>
00023
00024 #include <OSPRITE.H>
00025 #include <OPSCHOOL.H>
00026 #include <OPEERSCH.H>
00027 #include <OFINANCE.H>
00028
00029 #include <OFACULTY.H>
00030 #include <OSTUDENT.H>
00031 #include <ODEPTRES.H>
00032
00033 #include <OOPT.H>
00034 #include <OATHLETI.H>
00035 #include <ODEVELOP.H>
00036 #include <OFacilit.H>
00037 #include <OLibtech.H>
00038 #include <OStuOff.H>
00039 #include <OINVEST.H>
00040 #include <OMATH.H>
00041
00042 #include <ALL.H>
00043
00044
00045
00046
00047 static void init_doctoral_target();
00048
00049
00051
00052 }
00053
00054
00055
00056
00058
00059 }
00060
00061
00062
00063
00068
00069
00070
00071
00072 for (int k = 0; k < REVENUE_POLICY_COUNT + EXPENSE_POLICY_COUNT; k++) {
00073 if(optimization.opt1_button_group_array[k]!=NULL)
00074 optimization.opt1_button_group_array[k]->button_pressed=1;
00075 if(optimization.opt1_slider_group[k].init_flag!=0)
00076 optimization.opt1_slider_group[k].enable_flag=1;
00077 }
00078 for (k = 0; k < COST_RISE_POLICY_COUNT; k++) {
00079 if(optimization.opt2_button_group_array[k]!=NULL)
00080 optimization.opt2_button_group_array[k]->button_pressed=1;
00081 if(optimization.opt2_slider_group[k].init_flag!=0)
00082 optimization.opt2_slider_group[k].enable_flag=1;
00083 }
00084
00085
00086 int oldCursor = mouse_cursor.get_icon();
00087
00088 mouse_cursor.set_icon(CURSOR_WAITING);
00089
00090 info.prerun_year=1;
00091
00092 info.init_random_seed(0);
00093
00094 switch( scenId ) {
00095 case 0:
00096 default:
00097 create_pregame_object();
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 break;
00108 }
00109
00110 if ( info.prerun_year==1)
00111 mouse_cursor.set_icon(CURSOR_WAITING);
00112
00113 mouse_cursor.restore_icon(oldCursor);
00114
00115
00116
00117
00118
00119
00120
00121
00122 sys.run();
00123 }
00124
00125
00126
00127
00131
00132
00133
00134 generate_road();
00135
00136
00137
00138 generate_firm();
00139
00140
00141
00142
00143
00144
00145
00146 generate_plant();
00147
00148 }
00149
00150
00151
00152
00153
00154 void Battle::generate_road() {
00155 int blockWidth=10, blockHeight=8;
00156 int firmId=0;
00157
00158
00159
00160
00161 for( int yLoc=0 ; yLoc+blockHeight<=MAX_WORLD_Y_LOC*3/4 ; yLoc+=blockHeight ) {
00162 road_res.build_road(0, yLoc, MAX_WORLD_X_LOC-2, yLoc );
00163 }
00164
00165
00166
00167 for( int xLoc=0 ; xLoc+blockWidth<=MAX_WORLD_X_LOC ; xLoc+=blockWidth ) {
00168 road_res.build_road(xLoc, 0, xLoc, MAX_WORLD_Y_LOC-32 );
00169 }
00170 }
00171
00172
00173
00174
00176
00177 int blockWidth=10, blockHeight=8;
00178 int firmId=0;
00179 FirmInfo* firmInfo;
00180
00181 while(1) {
00182 if( ++firmId > firm_res.firm_count )
00183 break;
00184
00185 firmInfo = firm_res[firmId];
00186
00187
00188 if( !firmInfo->field_id && firmInfo->is_available() ) {
00189 create_firm(firmId);
00190 }
00191 }
00192
00193
00194
00195
00196
00197 firm_array.add_firm( 28, MAX_WORLD_Y_LOC-29, FIRM_STADIUM );
00198
00199 firm_array.add_firm( 48, MAX_WORLD_Y_LOC-29, FIRM_INDOOR_SPORTS );
00200 }
00201
00202
00203
00204
00205
00206 void Battle::create_firm(int firmId) {
00207 int blockWidth=10, blockHeight=8;
00208 FirmInfo* firmInfo = firm_res[firmId];
00209
00210 for( int yLoc=2, yCount=0 ; yLoc+blockHeight<=MAX_WORLD_Y_LOC ; yLoc+=blockHeight, yCount++ ) {
00211 for( int xLoc=2, xCount=0 ; xLoc+blockWidth<=MAX_WORLD_X_LOC ; xLoc+=blockWidth, xCount++ ) {
00212 if( firmInfo->loc_width > blockWidth-ROAD_WIDTH ||
00213 firmInfo->loc_height > blockHeight-ROAD_HEIGHT ) {
00214 continue;
00215 }
00216
00217 int buildXLoc = xLoc + (blockWidth-ROAD_WIDTH-firmInfo->loc_width)/2;
00218 int buildYLoc = yLoc + (blockHeight-ROAD_HEIGHT-firmInfo->loc_height)/2;
00219
00220 if( firmInfo->can_build(buildXLoc, buildYLoc) ) {
00221 firm_array.add_firm( buildXLoc, buildYLoc, firmId );
00222 return;
00223 }
00224 }
00225 }
00226 }
00227
00228
00229
00230
00231
00232 void Battle::generate_plant() {
00233 for( int yLoc=0 ; yLoc<MAX_WORLD_Y_LOC ; yLoc++ ) {
00234 for( int xLoc=0 ; xLoc<MAX_WORLD_X_LOC ; xLoc++ ) {
00235 Location* locPtr = world.get_loc(xLoc, yLoc);
00236
00237 if( !locPtr->is_empty() )
00238 continue;
00239
00240 if( m.random(3)==0 ) {
00241 int plantId = m.random(plant_res.plant_count)+1;
00242
00243 locPtr->set_plant(plantId, m.random(25), 75+m.random(25));
00244 }
00245 }
00246 }
00247 }
00248
00249
00250
00251
00253
00254 int unitId = 1;
00255 int xLoc, yLoc;
00256
00257
00258
00259
00260 for( xLoc=0 ; xLoc<MAX_WORLD_X_LOC ; xLoc++ ) {
00261 for( yLoc=0 ; yLoc<MAX_WORLD_Y_LOC ; yLoc++ ) {
00262 Location* locPtr = world.get_loc(xLoc, yLoc);
00263
00264 if( !locPtr->is_road() )
00265 continue;
00266
00267
00268 err_when( locPtr->is_walkable() && !locPtr->is_road() );
00269
00270 if( !m.random(6) ) {
00271 locPtr->set_sprite(unitId);
00272
00273
00274
00275 unitId++;
00276 }
00277
00278 }
00279 }
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 #ifdef DEBUG
00295 debug_msg("generate_sprite end: %d", unitId);
00296 #endif
00297 }
00298
00299
00300
00301
00303
00304 }
00305
00306
00307
00308
00310
00311 int i,j;
00312 StudentArray* stuArr;
00313 Department* deptPtr;
00314
00315 for ( i=department_array.size(); i>0; i-- ) {
00316 if (department_array.is_deleted(i) )
00317 continue;
00318
00319 deptPtr = department_array[i];
00320
00321
00322 for ( j=deptPtr->faculty_array.faculty_count; j>0; j-- ) {
00323 deptPtr->faculty_array[j]->update_history(UPDATE_ALL);
00324 }
00325 deptPtr->faculty_array.update_history(UPDATE_ALL);
00326
00327
00328 stuArr = &(department_array[i]->student_array);
00329
00330 for (j=stuArr->size(); j>0; j--) {
00331
00332 if ( stuArr->is_deleted(j) )
00333 continue;
00334
00335 stuArr->operator[](j)->update_history(UPDATE_ALL);
00336 }
00337 deptPtr->student_array.update_history(UPDATE_ALL);
00338
00339 deptPtr->course_array.update_history();
00340
00341 deptPtr->update_history(UPDATE_ALL);
00342 }
00343
00344 department_array.update_history(UPDATE_ALL);
00345
00346
00347
00348 stuArr = &(department_res.general_dept.student_array);
00349 for (j=stuArr->size(); j>0; j--) {
00350
00351 if ( stuArr->is_deleted(j) )
00352 continue;
00353
00354 stuArr->operator[](j)->update_history(UPDATE_ALL);
00355 }
00356
00357
00358
00359
00360
00361 for (i=0; i<school_res.peer_school_count; i++) {
00362
00363 school_res.peer_school_array[i].game_score = (float)m.fmax(20, math.get_random_snd(40,8));
00364 }
00365
00366
00367 player_school.init_game_score = 0;
00368 player_school.cur_game_score = 0;
00369 player_school.ultimate_game_score = 0;
00370
00371 player_school.init_pi();
00372 player_school.update_history(UPDATE_ALL);
00373 }
00374
00375
00376
00377
00379
00380 int i,j;
00381 CourseArray* courArr;
00382 Department* deptPtr;
00383
00384 for ( i=department_array.size(); i>0; i-- ) {
00385 if (department_array.is_deleted(i) )
00386 continue;
00387
00388 deptPtr = department_array[i];
00389
00390
00391
00392
00393 float doctorPct = 0; {
00394 char s = DOCTOR;
00395 doctorPct = player_school.student_level_pct[s] - player_school.student_level_pct[MASTER];
00396 }
00397
00398
00399 deptPtr->init_doctor_count = (int) (player_school.get_player_expected_student_count() * doctorPct / 4);
00400
00401
00402
00403 deptPtr->calc_research_dollar();
00404 deptPtr->doctors_per_research_dollar = math.safe_divide( deptPtr->init_doctor_count, deptPtr->total_research_dollar_direct*1000);
00405
00406
00407
00408 int totalBreakoutSections = 0;
00409 courArr = &(department_array[i]->course_array);
00410
00411 for (j=courArr->size(); j>0; j--) {
00412 if ( courArr->operator[](j)->teaching_method == BREAKOUT_LAB )
00413 totalBreakoutSections++;
00414 }
00415
00416 deptPtr->init_breakout_section_count = totalBreakoutSections;
00417
00418 deptPtr->breakout_section_by_doctor = (float) min((float)(totalBreakoutSections*TRIMESTER_PER_YEAR), (float)(DOCTORAL_AVERAGE_TEACHING_BREAKOUT_SECTIONS * deptPtr->init_doctor_count));
00419 }
00420 }
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445 void Battle::create_pregame_object() {
00446 int i;
00447
00448
00449
00450
00451
00452
00453
00454 sys.report_before_morerpt_or_deptlist=MODE_NORMAL;
00455 sys.report_before_help=MODE_NORMAL;
00456
00457 memset(&athletics_office, 0, sizeof(Athletics));
00458
00459 athletics_office.last_ncaa_level_input = player_school.athletic_program_intensity;
00460
00461 athletics_office.input_2_ncaa_level(player_school.athletic_program_intensity);
00462
00463 school_res.init_game();
00464
00465
00466
00467 create_static_game_object();
00468
00469 for (i=0; i<MAX_DEPARTMENT; i++) {
00470 int deptId = player_school.selected_department_list[i];
00471 if ( deptId <= 0 )
00472 break;
00473 else
00474 department_array.add(deptId);
00475 }
00476
00477 department_array.init_data();
00478
00479 department_res.calc_total_elective_course_pref();
00480
00481
00482
00483 athletics_office.init_data_pre_finance();
00484
00485
00486
00487 for( i=department_array.size() ; i>0 ; i--) {
00488 if( department_array.is_deleted(i) )
00489 continue;
00490
00491
00492 department_array[i]->course_array.next_trimester();
00493 sys.yield();
00494 }
00495
00496 box.progress_update(14);
00497
00498 player_school.generate_student();
00499
00500
00501
00502
00503
00504 finance.init_data_pre_enroll();
00505
00506 enroll_res.init_data();
00507
00508
00509
00510
00511
00512 init_doctoral_target();
00513 enroll_res.enroll_main(80);
00514
00515
00516
00517
00518
00519 for( i=department_array.size(); i>0; i--) {
00520 if( department_array.is_deleted(i) )
00521 continue;
00522
00523 Department* deptPtr = department_array[i];
00524
00525 deptPtr->generate_faculty();
00526 deptPtr->init_hiring();
00527 }
00528
00529
00530
00531 department_array.init_research();
00532
00533
00534
00535
00536
00537 facility_office.init_data_pre_finance();
00538
00539 finance.init_data();
00540
00541
00542
00543
00544 development_office.init_data();
00545 athletics_office.init_data();
00546
00547 library_tech_office.init_data();
00548
00549 student_office.init_data();
00550
00551 investment_office.init_data();
00552
00553
00554
00555 init_performance_indicator();
00556
00557 #if(GAME_VERSION>=200)
00558 info.update_distance_learning_variables(1);
00559 #endif
00560
00561 library_tech_office.init_data();
00562
00563 facility_office.init_data();
00564
00565
00566 finance.post_init_data();
00567
00568
00569
00570
00571 #ifdef DEBUG
00572 for (i=department_array.size(); i>0; i--) {
00573 Department *deptPtr;
00574
00575 deptPtr = department_array[i];
00576 err_when(i != deptPtr->department_recno);
00577 }
00578 #endif
00579
00580 #if(GAME_VERSION>=200)
00581 for ( i=department_array.size(); i>0; i-- ) {
00582 if (department_array.is_deleted(i))
00583 continue;
00584
00585 Department* deptPtr = department_array[i];
00586
00587 int arraySize = deptPtr->cur_faculty_array.size();
00588
00589 if ( arraySize != 0 )
00590 deptPtr->cur_faculty_array.zap();
00591 }
00592 #endif
00593
00594 box.progress_update(28);
00595 }
00596
00597
00598
00599
00603
00604 create_pregame_object();
00605 }
00606
00607