25 #define _CRT_SECURE_NO_DEPRECATE 48 m_rots.resize( a_num_crops );
51 for (
int i=0; i<a_num_crops; i++) {
58 sprintf( filename,
"%sFarmType_%d.rot",
62 inpfile = fopen(filename,
"r" );
65 " Unable to open file ", filename);
68 for (
int j=0; j<a_num_crops; j++) {
69 fscanf( inpfile,
"%d", (
int*)&(
m_rots[ j ]->CropNum[ i ]) );
70 for (
int k=0; k<4; k++) {
71 fscanf( inpfile,
"%d", (
int*)&
m_rots[ j ]->NewCrop[ i ][ k ] );
72 fscanf( inpfile,
"%d", &
m_rots[ j ]->Percent[ i ][ k ] );
77 sprintf( filename,
"FarmType_%d.stt", i );
79 inpfile = fopen(filename,
"r" );
82 " Unable to open file ", filename);
85 for (
int j=0; j<a_num_crops; j++) {
86 fscanf( inpfile,
"%d %d",
87 (
int*)&
m_start[ j ]->CropNum[ i ],
98 for (
unsigned int i=0; i<
m_rots.size(); i++) {
109 for (
int i=0; i<4; i++ ) {
110 int percent =
m_rots[ a_current_crop ]->Percent[ a_farmtype ][ i ];
114 (-1 ==
m_rots[ a_current_crop ]->Percent[ a_farmtype ][ i+1 ]) ||
115 (rand()%100 < percent) ) {
116 return m_rots[ a_current_crop ]->NewCrop[ a_farmtype ][ i ];
120 " Unable to recover crop type?!",
"");
131 for (
int i=0; i<num_crops; i++ ) {
132 int percent =
m_start[ i ]->Percent[ a_farmtype ];
134 if ( (num_crops==i) ||
135 (-1 ==
m_start[ i+1 ]->Percent[ a_farmtype ]) ||
136 (rand()%100 < percent) ) {
142 " Unable to recover crop type?!",
"");
CfgStr l_map_rotation_files_prefix("MAP_ROTATION_FILES_PREFIX", CFG_CUSTOM,"")
TTypesOfVegetation GetFirstCrop(int a_farmtype, bool *a_low_nutrient)
vector< Starter * > m_start
TTypesOfVegetation GetNextCrop(int a_farmtype, int a_current_crop)
CropRotation(int a_num_crops)
class MapErrorMsg * g_msg
String configurator entry class.
bool GetNutStatus(int a_plant_num)
vector< Rotation * > m_rots
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
class CropRotation * g_rotation