Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536// sc2k/sim/tile_queue.hpp — the simulation's shared tile-coordinate work queue.//// The original keeps one global 512-entry FIFO ring buffer used by every network flood-fill// (power, water, …). On overflow the enqueue advances the head, dropping the oldest entry.// This is a faithful model of that buffer.#pragma once#include <cstdint>#include <vector>
namespace sc2k {namespace detail {
struct TileQueue { explicit TileQueue(int dimension = 128) : capacity(dimension == 128 ? 512 : 4 * dimension * dimension + 1), qr(capacity), qc(capacity) {} int capacity; std::vector<int> qr, qc; int head = 0, tail = 0; void clear() { head = tail = 0; } void push(int r, int c) { qr[tail] = r; qc[tail] = c; tail = (tail + 1) % capacity; if (head == tail) head = (head + 1) % capacity; // full → drop oldest (the original's enqueue rule) } bool empty() const { return head == tail; } void pop(int& r, int& c) { r = qr[head]; c = qc[head]; head = (head + 1) % capacity; }};
} // namespace detail} // namespace sc2k