25 #define _CRT_SECURE_NO_DEPRECATE
47 m_rots.resize( a_num_crops );
50 for (
int i=0; i<a_num_crops; i++) {
57 sprintf( filename,
"%sFarmType_%d.rot",
61 inpfile = fopen(filename,
"r" );
64 " Unable to open file ", filename);
67 for (
int j=0; j<a_num_crops; j++) {
68 fscanf( inpfile,
"%d", (
int*)&(
m_rots[ j ]->CropNum[ i ]) );
69 for (
int k=0; k<4; k++) {
70 fscanf( inpfile,
"%d", (
int*)&
m_rots[ j ]->NewCrop[ i ][ k ] );
71 fscanf( inpfile,
"%d", &
m_rots[ j ]->Percent[ i ][ k ] );
76 sprintf( filename,
"FarmType_%d.stt", i );
78 inpfile = fopen(filename,
"r" );
81 " Unable to open file ", filename);
84 for (
int j=0; j<a_num_crops; j++) {
85 fscanf( inpfile,
"%d %d",
86 (
int*)&
m_start[ j ]->CropNum[ i ],
97 for (
unsigned int i=0; i<
m_rots.size(); i++) {
108 for (
int i=0; i<4; i++ ) {
109 int percent =
m_rots[ a_current_crop ]->Percent[ a_farmtype ][ i ];
113 (-1 ==
m_rots[ a_current_crop ]->Percent[ a_farmtype ][ i+1 ]) ||
114 (rand()%100 < percent) ) {
115 return m_rots[ a_current_crop ]->NewCrop[ a_farmtype ][ i ];
119 " Unable to recover crop type?!",
"");
130 for (
int i=0; i<num_crops; i++ ) {
131 int percent =
m_start[ i ]->Percent[ a_farmtype ];
133 if ( (num_crops==i) ||
134 (-1 ==
m_start[ i+1 ]->Percent[ a_farmtype ]) ||
135 (rand()%100 < percent) ) {
141 " Unable to recover crop type?!",
"");