int place_item(int x, int y) { int group = (userOperation->action == UserOperation::ACTION_BUILD)?userOperation->constructionGroup->group:-1; int size = 1; if (group < 0) { ok_dial_box("warning.mes", BAD, _ ("ERROR: group does not exist. This should not happen! Please consider filling a bug report to lincity-ng team, with the saved game and what you did :-) ")); return -1000; } assert(userOperation->constructionGroup->is_allowed_here(x,y,false)); if(userOperation->action == UserOperation::ACTION_BUILD) { userOperation->constructionGroup->placeItem(x, y); size = userOperation->constructionGroup->size; adjust_money(-userOperation->constructionGroup->getCosts()); } connect_transport(x - 2, y - 2, x + size + 1, y + size + 1); desert_water_frontiers(x - 1, y - 1, size + 2, size + 2); connect_rivers(x,y); return 0; }
void do_bulldoze_area(int x, int y) //arg1 was short fill { if (world(x, y)->reportingConstruction) { ConstructionManager::executeRequest ( new ConstructionDeletionRequest(world(x, y)->reportingConstruction)); } else { world(x, y)->flags &= ~(FLAG_POWER_CABLES_0 | FLAG_POWER_CABLES_90); if (world(x, y)->is_water()) { world(x, y)->type = CST_GREEN; world(x, y)->group = GROUP_BARE; world(x, y)->flags &= ~(FLAG_IS_RIVER); world(x, y)->flags |= FLAG_ALTERED; } else { world(x, y)->type = CST_DESERT; world(x, y)->group = GROUP_DESERT; } if (world(x, y)->construction) { ok_dial_box("fire.mes", BAD, _("ups, Bulldozer found a dangling reportingConstruction"));} //Here size is always 1 connect_transport(x - 2, y - 2, x + 1 + 1, y + 1 + 1); connect_rivers(x,y); desert_water_frontiers(x - 1, y - 1, 1 + 2, 1 + 2); } }
void OreMineDeletionRequest::execute() { int size = subject->constructionGroup->size; int x = subject->x; int y = subject->y; subject->detach(); delete subject; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { world(x + j, y + i)->flags &= ~(FLAG_POWER_CABLES_0 | FLAG_POWER_CABLES_90); if (world(x+j,y+i)->ore_reserve < ORE_RESERVE / 2) { world(x+j,y+i)->setTerrain(GROUP_WATER); world(x+j,y+i)->flags |= (FLAG_HAS_UNDERGROUND_WATER | FLAG_ALTERED); connect_rivers(x+j,y+i); } //update mps display if (mps_x == x + j && mps_y == y + i) { mps_set(x + j, y + i, MPS_MAP);} } } // update adjacencies connect_transport(x - 2, y - 2, x + size + 1, y + size + 1); desert_water_frontiers(x - 1, y - 1, size + 2, size + 2); }
void do_daily_ecology() //should be going to MapTile:: und handled during simulation { const int len = world.len(); const int area = len * len; for (int idx = 0; idx < area; ++idx) { /* approximately 3 monthes needed to turn bulldoze area into green */ if ((world(idx)->getLowerstVisibleGroup() == GROUP_DESERT) && (world(idx)->flags & FLAG_HAS_UNDERGROUND_WATER) && (rand() % 300 == 1)) { world(idx)->setTerrain(CST_GREEN); desert_water_frontiers( (idx % len) - 1, (idx / len) - 1, 1 + 2, 1 + 2); } } //TODO: depending on water, green can become trees // pollution can make desert // etc ... /*TODO incorporate do_daily_ecology to simulate_mappoints. */ }
void SetOnFire::execute() { unsigned short size = subject->constructionGroup->size; int x = subject->x; int y = subject->y; subject->detach(); delete subject; for (unsigned short i = 0; i < size; ++i) { for (unsigned short j = 0; j < size; ++j) { world(x + j, y + i)->flags &= ~(FLAG_POWER_CABLES_0 | FLAG_POWER_CABLES_90); fireConstructionGroup.placeItem(x+j, y+i); //update mps display if (mps_x == x + j && mps_y == y + i) { mps_set(x + j, y + i, MPS_MAP);} } } // update adjacencies connect_transport(x - 2, y - 2, x + size + 1, y + size + 1); desert_water_frontiers(x - 1, y - 1, size + 2, size + 2); }
void ConstructionDeletionRequest::execute() { //std::cout << "deleting: " << subject->constructionGroup->name //<< " (" << subject->x << "," << subject->y << ")" << std::endl; unsigned short size = subject->constructionGroup->size; int x = subject->x; int y = subject->y; subject->detach(); delete subject; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { //update mps display world(x + j, y + i)->flags &= ~(FLAG_POWER_CABLES_0 | FLAG_POWER_CABLES_90); if (mps_x == x + j && mps_y == y + i) { mps_set(x + j, y + i, MPS_MAP);} } } // update adjacencies connect_transport(x - 2, y - 2, x + size + 1, y + size + 1); desert_water_frontiers(x - 1, y - 1, size + 2, size + 2); }