Exemplo n.º 1
0
int
putDownNetwork(SimView *view, short mapH, short mapV)
{
  int tile = Map[mapH][mapV] & LOMASK;

  if ((TotalFunds > 0) && tally(tile)) {
    Map[mapH][mapV] = tile = 0;
    Spend(1);
  }

  if (tile == 0) {
    if ((TotalFunds - CostOf[view->tool_state]) >= 0) {
      Map[mapH][mapV] = TELEBASE | CONDBIT | BURNBIT | BULLBIT | ANIMBIT;
      Spend(CostOf[view->tool_state]);
      return 1;
    } else {
      return -2;
    }
  } else {
    return -1;
  }
}
Exemplo n.º 2
0
int
putDownPark(SimView *view, short mapH, short mapV)
{
  short value, tile;

  if (TotalFunds - CostOf[parkState] >= 0) {
    value = Rand(4);

    if (value == 4)
      tile = FOUNTAIN | BURNBIT | BULLBIT | ANIMBIT;
    else
      tile = (value + WOODS2) | BURNBIT | BULLBIT;

    if (Map[mapH][mapV] == 0) {
      Spend(CostOf[parkState]);
      UpdateFunds();
      Map[mapH][mapV] = tile;
      return 1;
    }
    return -1;
  }
  return -2;
}
Exemplo n.º 3
0
bool CCoins::Spend(int nPos) {
    CTxInUndo undo;
    COutPoint out(0, nPos);
    return Spend(out, undo);
}
Exemplo n.º 4
0
int
bulldozer_tool(SimView *view, short x, short y)
{
  unsigned short currTile, temp;
  short zoneSize, deltaH, deltaV;
  int result = 1;

  if ((x < 0) || (x > (WORLD_X - 1)) ||
      (y < 0) || (y > (WORLD_Y - 1))) {
    return -1;
  }

  currTile = Map[x][y];
  temp = currTile & LOMASK;

  if (currTile & ZONEBIT) { /* zone center bit is set */
    if (TotalFunds > 0) {
      Spend(1);
      switch (checkSize(temp)) {
      case 3:
	MakeSound("city", "Explosion-High");
	put3x3Rubble(x, y);
	break;

      case 4:
	put4x4Rubble(x, y);
	MakeSound("city", "Explosion-Low");
	break;

      case 6: 
	MakeSound("city", "Explosion-High");
	MakeSound("city", "Explosion-Low");
	put6x6Rubble(x, y);
	break;

      default:
	break;
      }
    }
  } else if ((zoneSize = checkBigZone(temp, &deltaH, &deltaV))) {
    if (TotalFunds > 0) {
      Spend(1);
      switch (zoneSize) {
      case 3:
	MakeSound("city", "Explosion-High");
	break;

      case 4:
	MakeSound("city", "Explosion-Low");
	put4x4Rubble(x + deltaH, y + deltaV);
	break;

      case 6: 
	MakeSound("city", "Explosion-High");
	MakeSound("city", "Explosion-Low");
	put6x6Rubble(x + deltaH, y + deltaV);
	break;
      }
    }
  } else {
    if (temp == RIVER || temp == REDGE || temp == CHANNEL) {
      if (TotalFunds >= 6) {
	result = ConnecTile(x, y, &Map[x][y], 1);
	if (temp != (Map[x][y] & LOMASK)) {
	  Spend(5);
	}
      } else {
	result = 0;
      }
    } else {
      result = ConnecTile(x, y, &Map[x][y], 1);
    }
  }
  UpdateFunds();
  if (result == 1) {
    DidTool(view, "Dozr", x, y);
  }
  return result;
}
Exemplo n.º 5
0
short
check6x6(SimView *view, short mapH, short mapV, short base, short tool)
{
  register short rowNum, columnNum;
  short h, v;
  short holdMapH;
  short xMap, yMap;
  short flag;
  short tileValue;
  short cost = 0;

  mapH--; mapV--;
  if ((mapH < 0) || (mapH > (WORLD_X - 6)) ||
      (mapV < 0) || (mapV > (WORLD_Y - 6)))
    return -1;

  h = xMap = holdMapH = mapH;
  v = yMap = mapV;

  flag = 1;

  for (rowNum = 0; rowNum <= 5; rowNum++) {
    mapH = holdMapH;

    for (columnNum = 0; columnNum <= 5; columnNum++) {
      tileValue = Map[mapH++][mapV] & LOMASK;

      if (autoBulldoze) {
	/* if autoDoze is enabled, add up the cost of bulldozed tiles */
	if (tileValue != 0)
	  if (tally(tileValue)) {
	    cost++;
	  } else {
	    flag = 0;
	  }
      } else {
	/* check and see if the tile is clear or not  */
	if (tileValue != 0) {
	  flag = 0;
	}
      }
    }
    mapV++;
  }

  if (flag == 0) {
    return -1;
  }

  cost += CostOf[tool];

  if ((TotalFunds - cost) < 0) {
    return -2;
  }

  if ((Players > 1) &&
      (OverRide == 0) &&
      (cost >= Expensive) &&
      (view != NULL) &&
      (view->super_user == 0)) {
    return -3;
  }

  /* take care of the money situtation here */
  Spend(cost);
  UpdateFunds();

  mapV = v; holdMapH = h;

  for (rowNum = 0; rowNum <= 5; rowNum++) {
    mapH = holdMapH;

    for (columnNum = 0; columnNum <= 5; columnNum++) {
      if (columnNum == 1 && rowNum == 1) {
	Map[mapH++][mapV] = base + BNCNBIT + ZONEBIT;
      } else {
	Map[mapH++][mapV] = base + BNCNBIT;
      }
      base++;
    }
    mapV++;
  }
  check6x6border(xMap, yMap);
  return 1;
}
Exemplo n.º 6
0
/* comefrom: processEvent */
doKeyDown(SimView *view, short charCode)
{
  LastKeys[0] = LastKeys[1];
  LastKeys[1] = LastKeys[2];
  LastKeys[2] = LastKeys[3];
  LastKeys[3] = tolower(charCode);

  if (strcmp(LastKeys, "fund") == 0) {
    Spend(-10000);
    PunishCnt++;				/* punish for cheating */
    if (PunishCnt == 5) {
      PunishCnt = 0;
      MakeEarthquake();
    }
    LastKeys[0] = '\0';
  } else if (strcmp(LastKeys, "fart") == 0) {
    MakeSound("city", "Explosion-High");
    MakeSound("city", "Explosion-Low");
    MakeFire();
    MakeFlood();
    MakeTornado();
    MakeEarthquake();
    MakeMonster();
    LastKeys[0] = '\0';
  } else if (strcmp(LastKeys, "nuke") == 0) {
    int i, j;
    MakeSound("city", "Explosion-High");
    MakeSound("city", "Explosion-Low");
    for (i = 0; i < WORLD_X; i++) {
      for (j = 0; j < WORLD_Y; j++) {
	short tile = Map[i][j] & LOMASK;
	if ((tile >= RUBBLE) &&
	    ((tile < CHURCH - 4) ||
	     (tile > CHURCH + 4))) {
	  if ((tile >= HBRIDGE && tile <= VBRIDGE) ||
	      (tile >= BRWH && tile <= LTRFBASE + 1) ||
	      (tile >= BRWV && tile <= BRWV + 2) ||
	      (tile >= BRWXXX1 && tile <= BRWXXX1 + 2) ||
	      (tile >= BRWXXX2 && tile <= BRWXXX2 + 2) ||
	      (tile >= BRWXXX3 && tile <= BRWXXX3 + 2) ||
	      (tile >= BRWXXX4 && tile <= BRWXXX4 + 2) ||
	      (tile >= BRWXXX5 && tile <= BRWXXX5 + 2) ||
	      (tile >= BRWXXX6 && tile <= BRWXXX6 + 2) ||
	      (tile >= BRWXXX7 && tile <= BRWXXX7 + 2)) {
	    Map[i][j] = RIVER;
	  } else {
	    Map[i][j] = TINYEXP + ANIMBIT + BULLBIT + Rand(2);
	  }
	}
      }
    }
    LastKeys[0] = '\0';
  } else if (strcmp(LastKeys, "stop") == 0) {
    heat_steps = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "will") == 0) {
    int i;
    int n = 500;
    for (i = 0; i < n; i++) {
      int x1 = Rand(WORLD_X - 1);
      int y1 = Rand(WORLD_Y - 1);
      int x2 = Rand(WORLD_X - 1);
      int y2 = Rand(WORLD_Y - 1);
      short temp =
	Map[x1][y1];
      Map[x1][y1] =
	Map[x2][y2];
      Map[x2][y2] =
	temp;
    }
    Kick();
  } else if (strcmp(LastKeys, "bobo") == 0) {
    heat_steps = 1;
    heat_flow = -1;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "boss") == 0) {
    heat_steps = 1;
    heat_flow = 1;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "mack") == 0) {
    heat_steps = 1;
    heat_flow = 0;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "donh") == 0) {
    heat_steps = 1;
    heat_flow = -1;
    heat_rule = 1;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "patb") == 0) {
    heat_steps = 1;
    heat_flow = Rand(40) - 20;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "lucb") == 0) {
    heat_steps = 1;
    heat_flow = Rand(1000) - 500;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "olpc") == 0) {
    Spend(-1000000);
  }

  switch (charCode) {
    
    case 'X':
    case 'x': {
      short s = view->tool_state;
      if (++s > lastState) {
	s = firstState;
      }
      setWandState(view, s);
      break;
    }

    case 'Z':
    case 'z': {
      short s = view->tool_state;
      if (--s < firstState) {
	  s = lastState;
      }
      setWandState(view, s);
      break;
    }

    /***** shift wand state to bull dozer *****/
    case 'B':
    case 'b':
    case 'B'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, dozeState);
      break;
    }

    /***** shift wand state to roads *****/
    case 'R':
    case 'r':
    case 'R'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, roadState);
      break;
    }

    /***** shift wand state to power *****/
    case 'P':
    case 'p':
    case 'P'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, wireState);
      break;
    }

    /***** shift wand state to transit *****/
    case 'T':
    case 't':
    case 'T'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, rrState);
      break;
    }

#if 0
    /***** shift wand state to query *****/
    case 'Q':
    case 'q':
    case 'Q'-'@': {
      if (view->tool_state_save == -1)
	view->tool_state_save = view->tool_state;
      setWandState(view, queryState);
      break;
    }
#endif

    case 27: {
      SoundOff();
      break;
    }

  }
}