/** ** Reveal the entire map. */ void CMap::Reveal() { // Mark every explored tile as visible. 1 turns into 2. Vec2i pos; for (pos.x = 0; pos.x < this->Info.MapWidth; ++pos.x) { for (pos.y = 0; pos.y < this->Info.MapHeight; ++pos.y) { for (int p = 0; p < PlayerMax; ++p) { if (!this->Field(pos)->Visible[p]) { this->Field(pos)->Visible[p] = 1; } } MarkSeenTile(pos); } } // Global seen recount. Simple and effective. for (CUnitManager::Iterator it = UnitManager.begin(); it != UnitManager.end(); ++it) { CUnit &unit = **it; // Reveal neutral buildings. Gold mines:) if (unit.Player->Type == PlayerNeutral) { for (int p = 0; p < PlayerMax; ++p) { if (Players[p].Type != PlayerNobody && (!(unit.Seen.ByPlayer & (1 << p)))) { UnitGoesOutOfFog(unit, Players[p]); UnitGoesUnderFog(unit, Players[p]); } } } UnitCountSeen(unit); } }
/** ** Reveal the entire map. */ void CMap::Reveal() { // Mark every explored tile as visible. 1 turns into 2. for (int i = 0; i != this->Info.MapWidth * this->Info.MapHeight; ++i) { CMapField &mf = *this->Field(i); CMapFieldPlayerInfo &playerInfo = mf.playerInfo; for (int p = 0; p < PlayerMax; ++p) { playerInfo.Visible[p] = std::max<unsigned short>(1, playerInfo.Visible[p]); } MarkSeenTile(mf); } // Global seen recount. Simple and effective. for (CUnitManager::Iterator it = UnitManager.begin(); it != UnitManager.end(); ++it) { CUnit &unit = **it; // Reveal neutral buildings. Gold mines:) if (unit.Player->Type == PlayerNeutral) { for (int p = 0; p < PlayerMax; ++p) { if (Players[p].Type != PlayerNobody && (!(unit.Seen.ByPlayer & (1 << p)))) { UnitGoesOutOfFog(unit, Players[p]); UnitGoesUnderFog(unit, Players[p]); } } } UnitCountSeen(unit); } }
void operator()(CUnit *const unit) const { if (cloak != (int)unit->Type->PermanentCloak) { return ; } const int p = player->Index; if (MARK) { // If the unit goes out of fog, this can happen for any player that // this player shares vision with, and can't YET see the unit. // It will be able to see the unit after the Unit->VisCount ++ if (!unit->VisCount[p]) { for (int pi = 0; pi < PlayerMax; ++pi) { if ((pi == p /*player->Index*/) || player->IsBothSharedVision(Players[pi])) { if (!unit->IsVisible(Players[pi])) { UnitGoesOutOfFog(*unit, Players[pi]); } } } } unit->VisCount[p/*player->Index*/]++; } else { /* * HACK: UGLY !!! * There is bug in Seen code conneded with * UnitActionDie and Cloacked units. */ if (!unit->VisCount[p] && unit->CurrentAction() == UnitActionDie) { return; } Assert(unit->VisCount[p]); unit->VisCount[p]--; // If the unit goes under of fog, this can happen for any player that // this player shares vision to. First of all, before unmarking, // every player that this player shares vision to can see the unit. // Now we have to check who can't see the unit anymore. if (!unit->VisCount[p]) { for (int pi = 0; pi < PlayerMax; ++pi) { if (pi == p/*player->Index*/ || player->IsBothSharedVision(Players[pi])) { if (!unit->IsVisible(Players[pi])) { UnitGoesUnderFog(*unit, Players[pi]); } } } } } }
void operator()(CUnit *const unit) const { //Wyrmgus start if (unit->Type == NULL) { fprintf(stderr, "Unit has no type: \"%s\" (%d, %d)\n", unit->Name.c_str(), unit->tilePos.x, unit->tilePos.y); return; } //Wyrmgus end //Wyrmgus start // if (cloak != (int)unit->Type->BoolFlag[PERMANENTCLOAK_INDEX].value) { if (cloak != (int)unit->Type->BoolFlag[PERMANENTCLOAK_INDEX].value || ethereal != (int)unit->Type->BoolFlag[ETHEREAL_INDEX].value) { //Wyrmgus end return ; } const int p = player->Index; if (MARK) { // If the unit goes out of fog, this can happen for any player that // this player shares vision with, and can't YET see the unit. // It will be able to see the unit after the Unit->VisCount ++ if (!unit->VisCount[p]) { for (int pi = 0; pi < PlayerMax; ++pi) { if ((pi == p /*player->Index*/) //Wyrmgus start // || player->IsBothSharedVision(Players[pi])) { || player->IsBothSharedVision(Players[pi]) || player->Revealed) { //Wyrmgus end if (!unit->IsVisible(Players[pi])) { UnitGoesOutOfFog(*unit, Players[pi]); } } } } unit->VisCount[p/*player->Index*/]++; } else { /* * HACK: UGLY !!! * There is bug in Seen code conneded with * UnitActionDie and Cloaked units. */ if (!unit->VisCount[p] && unit->CurrentAction() == UnitActionDie) { return; } Assert(unit->VisCount[p]); unit->VisCount[p]--; // If the unit goes under of fog, this can happen for any player that // this player shares vision to. First of all, before unmarking, // every player that this player shares vision to can see the unit. // Now we have to check who can't see the unit anymore. if (!unit->VisCount[p]) { for (int pi = 0; pi < PlayerMax; ++pi) { if (pi == p/*player->Index*/ || //Wyrmgus start // player->IsBothSharedVision(Players[pi])) { player->IsBothSharedVision(Players[pi]) || player->Revealed) { //Wyrmgus end if (!unit->IsVisible(Players[pi])) { UnitGoesUnderFog(*unit, Players[pi]); } } } } } }