コード例 #1
0
ファイル: port.cpp プロジェクト: SirIvanMoReau/lincity-ng
void Port::update()
{
    daily_ic = 0;
    daily_et = 0;

    if (commodityCount[STUFF_JOBS] >= PORT_JOBS)//there is enough workforce
    {
        trade_connection();
        if (daily_ic || daily_et)
        {
            commodityCount[STUFF_JOBS] -= PORT_JOBS;
            world(x,y)->pollution += PORT_POLLUTION;
            sust_port_flag = 0;
            tech_made++;
            tech_level++;
            working_days++;
            if (daily_ic && daily_et)
            {   tech_level++;}
        }
    }
    monthly_ic += daily_ic;
    monthly_et += daily_et;
    //monthly update
    if (total_time % 100 == 0)
    {
        busy = working_days;
        working_days = 0;
        lastm_ic = monthly_ic;
        lastm_et = monthly_et;
        monthly_ic = 0;
        monthly_et = 0;
    }

    daily_et += pence;
    export_tax += daily_et / 100;
    pence = daily_et % 100;
    import_cost += daily_ic;
}
コード例 #2
0
void
do_port (int x, int y)
{
  /*
     // int_1 is the money made so far this month
     // int_2 is the money made last month
     // int_3 holds the 'pence/pennies/bits' to add next time round.
     // int_4 is the import costs so far this month
     // int_5 is the import costs for last month
     // Use int_3 to int_7 of (x+1,y) to hold the individual buy values
     //                       (x,y+1) is last month's
     // Use int_3 to int_7 of (x+2,y) to hold the individual sell values
     //                       (x,y+2) is last month's
   */
  int i, et = 0, ic = 0, *b1, *b2, *s1, *s2, a;

      
 /* left connection first */
  for( a = 0; a < 4 ; a++ ) //try anywhere on the west side.
    if ( x >= 0 && y>=0 && (MP_INFO( x-1, y+a ).flags
              & FLAG_IS_TRANSPORT) != 0){
        trade_connection( x, y, x-1, y+a, &ic, &et );
        break;
    }
 /* upper gate next */
  bool deal = false;
  for( a = 0; a < 3 ; a++ ) //try north
    if ( x >= 0 && y>=0 && (MP_INFO( x+a, y-1 ).flags
              & FLAG_IS_TRANSPORT) != 0){
        trade_connection( x, y, x+a, y-1, &ic, &et );
        deal = false;
        break;
    }
  if( !deal )
  for( a = 0; a < 3 ; a++ ) //try south
    if ( x >= 0 && y>=0 && (MP_INFO( x+a, y+4 ).flags
              & FLAG_IS_TRANSPORT) != 0){
        trade_connection( x, y, x+a, y+4, &ic, &et );
        break;
    }
  
  MP_INFO(x,y).int_1 += et;
  MP_INFO(x,y).int_4 += ic;
  if (total_time % 100 == 0)
    {
      MP_INFO(x,y).int_2 = MP_INFO(x,y).int_1;
      MP_INFO(x,y).int_1 = 0;
      MP_INFO(x,y).int_5 = MP_INFO(x,y).int_4;
      MP_INFO(x,y).int_4 = 0;
      b1 = &(MP_INFO(x + 1,y).int_3);
      s1 = &(MP_INFO(x + 2,y).int_3);
      b2 = &(MP_INFO(x,y + 1).int_3);
      s2 = &(MP_INFO(x,y + 2).int_3);
      /* GCS FIX -- This obfuscation is unnecessary. */
      for (i = 0; i < 5; i++)
	{
	  *(b2++) = *b1;
	  *(s2++) = *s1;
	  *(b1++) = 0;
	  *(s1++) = 0;
	}
    }
  if (et > 0)
    {
      sust_port_flag = 0;
      tech_level++;
    }
  if (ic > 0)
    {
      sust_port_flag = 0;
      tech_level++;
    }
  et += MP_INFO(x,y).int_3;	/* int_3 holds the 'pence' */

  export_tax += et / 100;
  MP_INFO(x,y).int_3 = et % 100;
  import_cost += ic;
}