int ARegion::CanBeStartingCity( ARegionArray *pRA ) { if(type == R_OCEAN) return 0; if (!IsCoastal()) return 0; if (town && town->pop == 5000) return 0; int regs = 0; AList inlist; AList donelist; ARegionPtr * temp = new ARegionPtr; temp->ptr = this; inlist.Add(temp); while(inlist.Num()) { ARegionPtr * reg = (ARegionPtr *) inlist.First(); for (int i=0; i<NDIRS; i++) { ARegion * r2 = reg->ptr->neighbors[i]; if (!r2) continue; if (r2->type == R_OCEAN) continue; if (GetRegion(&inlist,r2->num)) continue; if (GetRegion(&donelist,r2->num)) continue; regs++; if (regs>20) return 1; ARegionPtr * temp = new ARegionPtr; temp->ptr = r2; inlist.Add(temp); } inlist.Remove(reg); donelist.Add(reg); } return 0; }
int AGetName(int town, ARegion *reg) { int unique, rnd, syllables, i, trail, port, similar; unsigned int u; char temp[80]; AString *name; port = 0; if (town) { for (i = 0; i < NDIRS; i++) if (reg->neighbors[i] && TerrainDefs[reg->neighbors[i]->type].similar_type == R_OCEAN) port = 1; } unique = 0; while (!unique) { rnd = getrandom(tSyll); for (syllables = 0; rnd >= syllprob[syllables]; syllables++) rnd -= syllprob[syllables]; syllables++; temp[0] = 0; trail = 0; while (syllables-- > 0) { if (!syllables) { // Might replace the last syllable with a // terrain specific suffix rnd = getrandom(400); similar = TerrainDefs[reg->type].similar_type; // Use forest names for underforest if (similar == R_UFOREST) similar = R_FOREST; // ocean (water) names for lakes if (similar == R_LAKE) similar = R_OCEAN; // and plains names for cavern if (similar == R_CAVERN) similar = R_PLAIN; for (u = 0; u < sizeof(ts) / sizeof(ts[0]); u++) { if (ts[u].terrain == similar || ts[u].terrain == -1 || (ts[u].town && town) || (ts[u].port && port)) { if (rnd >= ts[u].prob) rnd -= ts[u].prob; else { if (trail) { switch(ts[u].word[0]) { case 'a': case 'e': case 'i': case 'o': case 'u': strcat(temp, "'"); break; default: break; } } strcat(temp, ts[u].word); break; } } } if (u < sizeof(ts) / sizeof(ts[0])) break; } if (getrandom(5) > 0) { // 4 out of 5 syllables start with a consonant sequence rnd = getrandom(tIC); for (i = 0; rnd >= ic[i].prob; i++) rnd -= ic[i].prob; strcat(temp, ic[i].word); } else if (trail) { // separate adjacent vowels strcat(temp, "'"); } // All syllables have a vowel sequence rnd = getrandom(tV); for (i = 0; rnd >= v[i].prob; i++) rnd -= v[i].prob; strcat(temp, v[i].word); if (getrandom(5) > 1) { // 3 out of 5 syllables end with a consonant sequence rnd = getrandom(tFC); for (i = 0; rnd >= fc[i].prob; i++) rnd -= fc[i].prob; strcat(temp, fc[i].word); trail = 0; } else { trail = 1; } } temp[0] = toupper(temp[0]); unique = 1; forlist(®ionnames) { name = (AString *) elem; if (*name == temp) { unique = 0; break; } } if (strlen(temp) > 12) unique = 0; } nnames++; if (town) ntowns++; else nregions++; name = new AString(temp); regionnames.Add(name); return regionnames.Num(); }