Difference for server/weather.c from version 1.9 to 1.10


version 1.9 version 1.10
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_weather_c =   * static char *rcsid_weather_c =
  *   "$Id: weather.c,v 1.9 2002/10/29 09:00:44 garbled Exp $";   *   "$Id: weather.c,v 1.10 2002/10/29 10:24:53 garbled Exp $";
  */   */
 /*  /*
     CrossFire, A Multiplayer game for X-windows      CrossFire, A Multiplayer game for X-windows
Line 54
 
Line 54
 #define WEATHERMAPTILESX 100  #define WEATHERMAPTILESX 100
 #define WEATHERMAPTILESY 100  #define WEATHERMAPTILESY 100
   
   /* sky conditions */
   #define SKY_CLEAR         0
   #define SKY_LIGHTCLOUD    1
   #define SKY_OVERCAST      2
   #define SKY_LIGHT_RAIN    3
   #define SKY_RAIN          4 /* rain -> storm has lightning */
   #define SKY_HEAVY_RAIN    5
   #define SKY_HURRICANE     6
   /* wierd weather 7-12 */
   #define SKY_FOG           7
   #define SKY_HAIL          8
   /* snow */
   #define SKY_LIGHT_SNOW    13 /* add 10 to rain to get snow */
   #define SKY_SNOW          14
   #define SKY_HEAVY_SNOW    15
   #define SKY_BLIZZARD      16
   
 int gulf_stream_speed[GULF_STREAM_WIDTH][WEATHERMAPTILESY];  int gulf_stream_speed[GULF_STREAM_WIDTH][WEATHERMAPTILESY];
 int gulf_stream_dir[GULF_STREAM_WIDTH][WEATHERMAPTILESY];  int gulf_stream_dir[GULF_STREAM_WIDTH][WEATHERMAPTILESY];
 int gulf_stream_start;  int gulf_stream_start;
Line 146
 
Line 163
      write_temperaturemap();       write_temperaturemap();
  if (todtick%27 == 0)   if (todtick%27 == 0)
      write_gulfstreammap();       write_gulfstreammap();
    if (todtick%28 == 0 && settings.fastclock > 0)
        write_skymap();
     }      }
     get_tod(&tod);      get_tod(&tod);
     dawn_to_dusk(&tod);      dawn_to_dusk(&tod);
Line 156
 
Line 175
  plot_gulfstream();   plot_gulfstream();
         update_humid();          update_humid();
         init_temperature();          init_temperature();
    compute_sky();
     }      }
     /* perform_weather must follow calculators */      /* perform_weather must follow calculators */
     perform_weather();      perform_weather();
Line 174
 
Line 194
  * calls the init function, to initialize that map.   * calls the init function, to initialize that map.
  */   */
   
   /* sky. We never read this map, only write it for debugging purposes */
   
   void write_skymap()
   {
       char filename[MAX_BUF];
       FILE *fp;
       int x, y;
   
       sprintf(filename, "%s/skymap", settings.localdir);
       if ((fp = fopen(filename, "w")) == NULL) {
    LOG(llevError, "Cannot open %s for writing\n", filename);
    return;
       }
       for (x=0; x < WEATHERMAPTILESX; x++) {
    for (y=0; y < WEATHERMAPTILESY; y++)
        fprintf(fp, "%d ", weathermap[x][y].sky);
    fprintf(fp, "\n");
       }
       fclose(fp);
   }
   
 /* pressure */  /* pressure */
   
 void write_pressuremap()  void write_pressuremap()
Line 1192
 
Line 1233
     }      }
   
     /* windchill */      /* windchill */
     for (i=0; i < weathermap[x][y].windspeed; i+=i)      for (i=1; i < weathermap[x][y].windspeed; i+=i)
  temp--;   temp--;
   
     return temp;      return temp;
Line 1432
 
Line 1473
  gulf_stream_start++;   gulf_stream_start++;
   
 }  }
   
   /* let the madness, begin. */
   
   void compute_sky()
   {
       int x, y;
       int temp;
   
       for (x=0; x < WEATHERMAPTILESX; x++) {
    for (y=0; y < WEATHERMAPTILESY; y++) {
        temp = real_temperature(x, y);
        if (weathermap[x][y].pressure < 980) {
    if (weathermap[x][y].humid < 20)
        weathermap[x][y].sky = SKY_LIGHTCLOUD;
    else if (weathermap[x][y].humid < 30)
        weathermap[x][y].sky = SKY_OVERCAST;
    else if (weathermap[x][y].humid < 40)
        weathermap[x][y].sky = SKY_LIGHT_RAIN;
    else if (weathermap[x][y].humid < 55)
        weathermap[x][y].sky = SKY_RAIN;
    else if (weathermap[x][y].humid < 70)
        weathermap[x][y].sky = SKY_HEAVY_RAIN;
    else
        weathermap[x][y].sky = SKY_HURRICANE;
    if (weathermap[x][y].sky < SKY_HURRICANE &&
        weathermap[x][y].windspeed > 30)
        weathermap[x][y].sky++;
    if (temp <= 0 && weathermap[x][y].sky > SKY_OVERCAST)
        weathermap[x][y].sky += 10; /*let it snow*/
        } else if (weathermap[x][y].pressure < 1000) {
    if (weathermap[x][y].humid < 10)
        weathermap[x][y].sky = SKY_CLEAR;
    else if (weathermap[x][y].humid < 25)
        weathermap[x][y].sky = SKY_LIGHTCLOUD;
    else if (weathermap[x][y].humid < 45)
        weathermap[x][y].sky = SKY_OVERCAST;
    else if (weathermap[x][y].humid < 60)
        weathermap[x][y].sky = SKY_LIGHT_RAIN;
    else if (weathermap[x][y].humid < 75)
        weathermap[x][y].sky = SKY_RAIN;
    else
        weathermap[x][y].sky = SKY_HEAVY_RAIN;
    if (weathermap[x][y].sky < SKY_HURRICANE &&
        weathermap[x][y].windspeed > 30)
        weathermap[x][y].sky++;
    if (temp <= 0 && weathermap[x][y].sky > SKY_OVERCAST)
        weathermap[x][y].sky += 10; /*let it snow*/
    if (temp > 0 && temp < 5 && weathermap[x][y].humid > 95 &&
        weathermap[x][y].windspeed < 3)
        weathermap[x][y].sky = SKY_FOG; /* rare */
    if (temp > 0 && temp < 5 && weathermap[x][y].humid > 70 &&
        weathermap[x][y].windspeed > 35)
        weathermap[x][y].sky = SKY_HAIL; /* rare */
        } else if (weathermap[x][y].pressure < 1020) {
    if (weathermap[x][y].humid < 20)
        weathermap[x][y].sky = SKY_CLEAR;
    else if (weathermap[x][y].humid < 30)
        weathermap[x][y].sky = SKY_LIGHTCLOUD;
    else if (weathermap[x][y].humid < 40)
        weathermap[x][y].sky = SKY_OVERCAST;
    else if (weathermap[x][y].humid < 55)
        weathermap[x][y].sky = SKY_LIGHT_RAIN;
    else if (weathermap[x][y].humid < 70)
        weathermap[x][y].sky = SKY_RAIN;
    else
        weathermap[x][y].sky = SKY_HEAVY_RAIN;
    if (weathermap[x][y].sky < SKY_HURRICANE &&
        weathermap[x][y].windspeed > 30)
        weathermap[x][y].sky++;
    if (temp <= 0 && weathermap[x][y].sky > SKY_OVERCAST)
        weathermap[x][y].sky += 10; /*let it snow*/
        } else {
    if (weathermap[x][y].humid < 35)
        weathermap[x][y].sky = SKY_CLEAR;
    else if (weathermap[x][y].humid < 55)
        weathermap[x][y].sky = SKY_LIGHTCLOUD;
    else if (weathermap[x][y].humid < 70)
        weathermap[x][y].sky = SKY_OVERCAST;
    else if (weathermap[x][y].humid < 85)
        weathermap[x][y].sky = SKY_LIGHT_RAIN;
    else if (weathermap[x][y].humid < 95)
        weathermap[x][y].sky = SKY_RAIN;
    else
        weathermap[x][y].sky = SKY_HEAVY_RAIN;
    if (weathermap[x][y].sky < SKY_HURRICANE &&
        weathermap[x][y].windspeed > 30)
        weathermap[x][y].sky++;
    if (temp <= 0 && weathermap[x][y].sky > SKY_OVERCAST)
        weathermap[x][y].sky += 10; /*let it snow*/
        }
    }
       }
   }


Legend:
line(s) removed in v.1.9 
line(s) changed
 line(s) added in v.1.10

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:53