Skip to content

Commit

Permalink
Initial cut of ring map
Browse files Browse the repository at this point in the history
  • Loading branch information
jt-traub committed Jul 1, 2024
1 parent 8956364 commit fbd23f2
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 6 deletions.
2 changes: 2 additions & 0 deletions aregion.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ class ARegionList : public AList
void CreateNexusLevel(int level, int xSize, int ySize, char const *name);
void CreateSurfaceLevel(int level, int xSize, int ySize, char const *name);
void CreateNaturalSurfaceLevel(Map* map);
void CreateIslandRingLevel(int level, int xSize, int ySize, char const *name);
void CreateIslandLevel(int level, int nPlayers, char const *name);
void CreateUnderworldLevel(int level, int xSize, int ySize, char const *name);
void CreateUnderdeepLevel(int level, int xSize, int ySize, char const *name);
Expand Down Expand Up @@ -530,6 +531,7 @@ class ARegionList : public AList
void SetRegTypes(ARegionArray *pRegs, int newType);
void MakeLand(ARegionArray *pRegs, int percentOcean, int continentSize);
void MakeCentralLand(ARegionArray *pRegs);
void MakeRingLand(ARegionArray *pRegs, int minDistance, int maxDistance);

void SetupAnchors(ARegionArray *pArr);
void GrowTerrain(ARegionArray *pArr, int growOcean);
Expand Down
7 changes: 7 additions & 0 deletions basic/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ void ARegionList::CreateIslandLevel(int level, int nPlayers, char const *name)
FinalSetup(pRegionArrays[level]);
}

void ARegionList::CreateIslandRingLevel(int level, int xSize, int ySize, char const *name)
{
throw "CreateIslandRingLevel not implemented for this game ruleset";
}

void ARegionList::CreateUnderworldLevel(int level, int xSize, int ySize,
char const *name)
{
Expand Down Expand Up @@ -524,6 +529,8 @@ void ARegionList::MakeLand(ARegionArray *pRegs, int percentOcean,
Awrite("");
}

void ARegionList::MakeRingLand(ARegionArray *pReg, int minDistance, int maxDistance) { }

void ARegionList::MakeCentralLand(ARegionArray *pRegs)
{
for (int i = 0; i < pRegs->x; i++) {
Expand Down
7 changes: 7 additions & 0 deletions fracas/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ void ARegionList::CreateIslandLevel(int level, int nPlayers, char const *name)
FinalSetup(pRegionArrays[level]);
}

void ARegionList::CreateIslandRingLevel(int level, int xSize, int ySize, char const *name)
{
throw "CreateIslandRingLevel not implemented for this game ruleset";
}

void ARegionList::CreateUnderworldLevel(int level, int xSize, int ySize,
char const *name)
{
Expand Down Expand Up @@ -524,6 +529,8 @@ void ARegionList::MakeLand(ARegionArray *pRegs, int percentOcean,
Awrite("");
}

void ARegionList::MakeRingLand(ARegionArray *pReg, int minDistance, int maxDistance) { }

void ARegionList::MakeCentralLand(ARegionArray *pRegs)
{
for (int i = 0; i < pRegs->x; i++) {
Expand Down
7 changes: 7 additions & 0 deletions havilah/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ void ARegionList::CreateIslandLevel(int level, int nPlayers, char const *name)
FinalSetup(pRegionArrays[level]);
}

void ARegionList::CreateIslandRingLevel(int level, int xSize, int ySize, char const *name)
{
throw "CreateIslandRingLevel not implemented for this game ruleset";
}

void ARegionList::CreateUnderworldLevel(int level, int xSize, int ySize,
char const *name)
{
Expand Down Expand Up @@ -532,6 +537,8 @@ void ARegionList::MakeLand(ARegionArray *pRegs, int percentOcean,
Awrite("");
}

void ARegionList::MakeRingLand(ARegionArray *pReg, int minDistance, int maxDistance) { }

void ARegionList::MakeCentralLand(ARegionArray *pRegs)
{
for (int i = 0; i < pRegs->x; i++) {
Expand Down
42 changes: 42 additions & 0 deletions neworigins/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,20 @@ void ARegionList::CreateIslandLevel(int level, int nPlayers, char const *name)
FinalSetup(pRegionArrays[level]);
}

void ARegionList::CreateIslandRingLevel(int level, int xSize, int ySize, char const *name)
{
MakeRegions(level, xSize, ySize);
pRegionArrays[level]->SetName(name);
pRegionArrays[level]->levelType = ARegionArray::LEVEL_SURFACE;

MakeRingLand(pRegionArrays[level], 30, 70);
RandomTerrain(pRegionArrays[level]);

if (Globals->LAKES) RemoveCoastalLakes(pRegionArrays[level]);
if (Globals->GROW_RACES) GrowRaces(pRegionArrays[level]);
FinalSetup(pRegionArrays[level]);
}

void ARegionList::CreateUnderworldLevel(int level, int xSize, int ySize,
char const *name)
{
Expand Down Expand Up @@ -2188,6 +2202,34 @@ void ARegionList::MakeLand(ARegionArray *pRegs, int percentOcean,
Awrite("");
}

void ARegionList::MakeRingLand(ARegionArray *pRegs, int minDistance, int maxDistance) {
ARegion *center = pRegs->GetRegion(pRegs->x / 2, pRegs->y / 2);
if (!center) { throw "Center region not found"; }

Awrite("Making land in ring");
for (int i = 0; i < pRegs->x; i++) {
for (int j = 0; j < pRegs->y; j++) {
ARegion *reg = pRegs->GetRegion(i, j);
if (!reg) continue;
// By default, everything is ocean
reg->type = R_OCEAN;

// If the regions is between minDistance and maxDistance from the center, default it to land.
int distance = GetPlanarDistance(center, reg, 1000, -1);
if (distance >= minDistance && distance <= maxDistance) {
reg->type = R_NUM;
} else if (distance >= maxDistance && (i > 4 || i <= pRegs->x - 4 || j > 4 || j <= pRegs->y - 4)) {
// If the distance is outside the ring but not too close to the edge, it has a 50% chance of being land.
if (getrandom(100) > 50) reg->type = R_NUM;
} else if (distance < minDistance && distance > 4) {
// If the distance is inside the ring, and not too close to the center, it has a 15% chance of being land.
if (getrandom(100) < 15) reg->type = R_NUM;
}
}
}
Awrite("");
}

void ARegionList::MakeCentralLand(ARegionArray *pRegs)
{
for (int i = 0; i < pRegs->x; i++) {
Expand Down
12 changes: 6 additions & 6 deletions neworigins/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ void Game::CreateWorld()
}

int generator = -1;
while (generator != 1 && generator != 2) {
Awrite("Selected surface land generator? [Origianl - 1, Parametrical - 2]");
while (generator < 1 || generator > 3) {
Awrite("Selected surface land generator? [Origianl - 1, Parametrical - 2, Island Ring - 3]");
generator = Agetint();
}

Expand All @@ -417,23 +417,23 @@ void Game::CreateWorld()
}
}

regions.CreateLevels(2 + Globals->UNDERWORLD_LEVELS +
Globals->UNDERDEEP_LEVELS + Globals->ABYSS_LEVEL);
regions.CreateLevels(2 + Globals->UNDERWORLD_LEVELS + Globals->UNDERDEEP_LEVELS + Globals->ABYSS_LEVEL);

SetupNames();

regions.CreateNexusLevel( 0, nx, ny, "nexus" );
if (generator == 1) {
regions.CreateSurfaceLevel( 1, xx, yy, 0 );
}
else {
} else if (generator == 2) {
Map* map = new Map(xx * 2, yy * 2);
map->redistribution = 1.5;
map->evoparation = 0.75;
map->mountainPercent = 0.1;
map->waterPercent = 0.1;

regions.CreateNaturalSurfaceLevel(map);
} else if (generator == 3) {
regions.CreateIslandRingLevel(1, xx, yy, 0);
}

// Create underworld levels
Expand Down
7 changes: 7 additions & 0 deletions standard/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ void ARegionList::CreateIslandLevel(int level, int nPlayers, char const *name)
FinalSetup(pRegionArrays[level]);
}

void ARegionList::CreateIslandRingLevel(int level, int xSize, int ySize, char const *name)
{
throw "CreateIslandRingLevel not implemented for this game ruleset";
}

void ARegionList::CreateUnderworldLevel(int level, int xSize, int ySize,
char const *name)
{
Expand Down Expand Up @@ -511,6 +516,8 @@ void ARegionList::MakeLand(ARegionArray *pRegs, int percentOcean,
Awrite("");
}

void ARegionList::MakeRingLand(ARegionArray *pReg, int minDistance, int maxDistance) { }

void ARegionList::MakeCentralLand(ARegionArray *pRegs)
{
for (int i = 0; i < pRegs->x; i++) {
Expand Down
3 changes: 3 additions & 0 deletions unittest/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void ARegionList::CreateSurfaceLevel(int level, int xSize, int ySize, char const
}

void ARegionList::CreateIslandLevel(int level, int nPlayers, char const *name) { }
void ARegionList::CreateIslandRingLevel(int level, int xSize, int ySize, char const *name) {}

void ARegionList::CreateUnderworldLevel(int level, int xSize, int ySize, char const *name) {
MakeRegions(level, xSize, ySize);
Expand Down Expand Up @@ -111,6 +112,8 @@ void ARegionList::SetupIcosahedralNeighbors(ARegionArray *pRegs) { }

void ARegionList::MakeLand(ARegionArray *pRegs, int percentOcean, int continentSize) { }

void ARegionList::MakeRingLand(ARegionArray *pReg, int minDistance, int maxDistance) { }

void ARegionList::MakeCentralLand(ARegionArray *pRegs) { }

void ARegionList::MakeIslands(ARegionArray *pArr, int nPlayers) { }
Expand Down

0 comments on commit fbd23f2

Please sign in to comment.