commit f197debe1cb08aca0a9058860337c8a6e430b01c
parent dc8c97c41a952cb8980bb575ddfd3e4781725286
Author: anon <anon@example.com>
Date: Fri, 6 Nov 2026 06:05:03 +0000
Generate short unique syllable names for new visitors
Diffstat:
11 files changed, 317 insertions(+), 31 deletions(-)
diff --git a/client/tests/browser_accounts.mjs b/client/tests/browser_accounts.mjs
@@ -56,7 +56,7 @@ const heads = [{mesh: 40681, breed: 1, sex: 2, race: 1}, {mesh: 40629, breed: 1,
test('Options offers visitor account flows with credentials hidden until a choice', async () => {
const page = accountPage();
- page.replies.push(response(200, {name: 'Visitor1', visitor: true, heads}));
+ page.replies.push(response(200, {name: 'Lupeza', visitor: true, heads}));
await page.open();
@@ -64,7 +64,7 @@ test('Options offers visitor account flows with credentials hidden until a choic
assert.equal(page.element('#password-button').hidden, true);
assert.equal(page.element('#account-choices').disabled, false);
assert.equal(page.element('#account-form').hidden, true);
- assert.match(page.element('#account-current').textContent, /Playing as Visitor1/);
+ assert.match(page.element('#account-current').textContent, /Playing as Lupeza/);
assert.equal(page.element('#account-password').value, '');
assert.equal(page.requests[0].url, 'browser-account');
});
@@ -195,7 +195,7 @@ for (const reply of [response(401, 'Reconnect to continue.'), new Error('Offline
test('breed and sex filter original heads, including the androgynous Atrox template', async () => {
const page = accountPage();
- page.replies.push(response(200, {name: 'Visitor1', visitor: true, heads}));
+ page.replies.push(response(200, {name: 'Lupeza', visitor: true, heads}));
await page.open();
page.choose('create');
diff --git a/docs/browser-accounts.md b/docs/browser-accounts.md
@@ -9,11 +9,12 @@ Closing the dialog returns focus to the canvas; Tab remains native targeting.
Mobile retains its existing toolbar and touch controls. The dialog scrolls on
small screens.
-A Visitor can choose a player name and password in Options without creating a
-replacement character. The player ID, items, XP, skills, resources, location,
+A visitor can keep its generated name or choose a new name and password in
+Options without creating a replacement character. The player ID, items, XP,
+skills, resources, location,
team and native per-character preferences remain attached to that character.
Options first offers Create character from scratch, Adopt this visitor, and
-Log in to an existing character. Adoption is hidden for named characters.
+Log in to an existing character. Adoption is hidden for already adopted characters.
Adopted and newly created players also have Change password, with a single
New password field. Saving keeps the current browser credential and game
connections and does not reload the page. Visitors cannot change passwords.
@@ -76,11 +77,30 @@ requires Go 1.26, which is now the declared build/test minimum. Password hashing
runs outside the simulation/database locks; a separate mutex bounds its memory
use without serializing the simulation with expensive password work.
-Names follow the original creator: remove characters other than ASCII letters
-and digits, capitalize the first letter and lowercase the rest, then require
+New visitors receive a pronounceable 6-8 letter name, such as Lupeza, Carozu
+or Bleronim. The curated beginning/middle/ending lists contain 165, 75 and 300
+syllables. Filtering recognizable profanity, slurs and reviewed awkward
+combinations leaves **3,602,718 distinct names**: 494,983 of length six,
+1,882,830 of length seven and 1,224,905 of length eight. The capacity regression
+counts every usable combination and verifies unique parts, prefix-free
+beginnings and fixed-length middles, which make concatenation unambiguous.
+The sample review and independent calculation are retained in
+`local/visitor-names/capacity.json` and `tmp_capacity.py`.
+
+Allocation checks the indexed database names without ASCII case distinctions
+and retries collisions without numeric suffixes. A unique index protects all
+player names, including unclaimed visitors; NPCs can still share names. The
+saved name survives reconnect/restart. Visitor/adopted status follows the
+stored password credential, not the name's spelling, so a visitor can adopt
+its generated name without losing its character or mistaking itself for a
+duplicate account.
+
+User-chosen names follow the original creator: remove characters other than
+ASCII letters and digits, capitalize the first letter and lowercase the rest,
+then require
4-12 characters with four initial letters and optional trailing digits.
-Letters cannot follow digits. NUL-containing input is rejected. Visitor-prefixed
-names are reserved, and names are unique without ASCII case distinctions.
+Letters cannot follow digits. NUL-containing input is rejected, and names are
+unique without ASCII case distinctions.
Original server profanity/reservation lists remain unknown. Login applies the
same normalization. Passwords may be empty and are limited to 1024
bytes, without trimming, case folding or composition rules.
diff --git a/server/browser_account.go b/server/browser_account.go
@@ -40,7 +40,7 @@ func (server *server) browserAccountInfo(w http.ResponseWriter, r *http.Request)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
- name, visitor := player.name, !claimed && player.name == fmt.Sprintf("Visitor%d", player.id)
+ name, visitor := player.name, !claimed
server.mutex.Unlock()
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]any{"name": name, "visitor": visitor, "adopted": claimed, "heads": gamedata.PlayerAppearances.Heads})
@@ -131,16 +131,8 @@ func (server *server) browserAccount(w http.ResponseWriter, r *http.Request) {
}
player := server.characters[id]
if action != "login" {
- if action == "claim" && current.name != fmt.Sprintf("Visitor%d", currentID) {
- http.Error(w, "This player already has a name.", http.StatusConflict)
- return
- }
- if strings.HasPrefix(strings.ToLower(name), "visitor") {
- http.Error(w, "Visitor names are reserved. Choose another name.", http.StatusBadRequest)
- return
- }
for _, other := range server.characters {
- if !other.npc && strings.EqualFold(other.name, name) {
+ if !other.npc && strings.EqualFold(other.name, name) && (action != "claim" || other.id != currentID) {
http.Error(w, "That player name is already in use.", http.StatusConflict)
return
}
diff --git a/server/browser_account_test.go b/server/browser_account_test.go
@@ -101,7 +101,7 @@ func TestBrowserAccountLoginSwitchesOnlyAfterCorrectPassword(t *testing.T) {
restored := newTestInventoryServer(t)
if response.Code != 204 || len(response.Result().Cookies()) != 1 || world.characters[1].browserTokenHash == firstHash || world.characters[2].browserTokenHash == visitorHash ||
- world.characters[1].name != "Alice" || world.characters[2].name != "Visitor2" || world.characters[2].position != before.position {
+ world.characters[1].name != "Alice" || world.characters[2].name != before.name || world.characters[2].position != before.position {
t.Fatalf("login did not replace the credentials without moving players: %d %s", response.Code, response.Body.String())
}
request := httptest.NewRequest("GET", "/", nil)
@@ -121,7 +121,7 @@ func TestBrowserAccountLoginSwitchesOnlyAfterCorrectPassword(t *testing.T) {
func TestBrowserAccountRejectsInvalidClaimsWithoutChangingVisitor(t *testing.T) {
for _, scenario := range []struct{ name, password string }{
{"", "password"}, {"123Alice", "password"}, {"Abc", "password"}, {"Al\x00ice", "password"}, {"Ali1ce", "password"},
- {strings.Repeat("a", 255), "password"}, {"Visitor42", "password"}, {"vIsItOrAlice", "password"}, {"Alice", strings.Repeat("a", 1025)},
+ {strings.Repeat("a", 255), "password"}, {"Alice", strings.Repeat("a", 1025)},
} {
t.Run(fmt.Sprintf("name=%q/length=%d", scenario.name, len(scenario.password)), func(t *testing.T) {
world := newTestServer(t)
@@ -145,12 +145,13 @@ func TestBrowserAccountDuplicateNamesAndRepeatedClaim(t *testing.T) {
t.Fatal(firstClaim.Body.String())
}
second := accountVisitor(t, world)
+ secondName := world.characters[2].name
duplicate := accountRequest(world, second, "claim", "ALICE", "other password")
repeated := accountRequest(world, firstClaim.Result().Cookies()[0], "claim", "Bobby", "replacement password")
login := accountRequest(world, second, "login", "Alice", "password")
- if duplicate.Code != 409 || repeated.Code != 409 || login.Code != 204 || world.characters[1].name != "Alice" || world.characters[2].name != "Visitor2" {
+ if duplicate.Code != 409 || repeated.Code != 409 || login.Code != 204 || world.characters[1].name != "Alice" || world.characters[2].name != secondName {
t.Fatalf("name collision changed accounts: %d %d %d", duplicate.Code, repeated.Code, login.Code)
}
}
diff --git a/server/browser_creation_test.go b/server/browser_creation_test.go
@@ -152,7 +152,7 @@ func TestBrowserCreationCatalogRequiresCookieAndExcludesCredentials(t *testing.T
decoder.DisallowUnknownFields()
err := decoder.Decode(&result)
- if err != nil || response.Code != 200 || response.Header().Get("Cache-Control") != "no-store" || result.Name != "Visitor1" || !result.Visitor || result.Adopted ||
+ if err != nil || response.Code != 200 || response.Header().Get("Cache-Control") != "no-store" || result.Name != world.characters[1].name || !result.Visitor || result.Adopted ||
!reflect.DeepEqual(result.Heads, gamedata.PlayerAppearances.Heads) || unauthorized.Code != 401 {
t.Fatalf("creation catalog: %d %v", response.Code, err)
}
@@ -205,7 +205,7 @@ func TestBrowserCreationRejectsInvalidChoicesWithoutChangingCurrentPlayer(t *tes
for _, scenario := range []struct{ field, value string }{
{"head_mesh", ""}, {"head_mesh", "1"}, {"head_mesh", "4294967296"}, {"profession", "0"}, {"profession", "13"}, {"profession", "-1"},
{"side", ""}, {"side", "3"}, {"side", "-1"}, {"build", "3"}, {"build", "normal"}, {"height", "0"}, {"height", "95"}, {"height", "65536"},
- {"name", "Abc"}, {"name", "Abc1"}, {"name", "Alice1a"}, {"name", "Thirteenchars"}, {"name", "Visitor42"}, {"password", strings.Repeat("a", 1025)},
+ {"name", "Abc"}, {"name", "Abc1"}, {"name", "Alice1a"}, {"name", "Thirteenchars"}, {"password", strings.Repeat("a", 1025)},
} {
t.Run(scenario.field+"="+scenario.value, func(t *testing.T) {
fields := creationForm()
diff --git a/server/browser_launch.go b/server/browser_launch.go
@@ -32,7 +32,6 @@ func (server *server) browserLaunch(w http.ResponseWriter, r *http.Request) {
if character == nil {
token := rand.Text()
character = server.newCharacter_locked()
- character.name = fmt.Sprintf("Visitor%d", character.id)
character.running = true
character.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte(token)))
character.playfield = 705
@@ -49,7 +48,7 @@ func (server *server) browserLaunch(w http.ResponseWriter, r *http.Request) {
head := heads[mathrand.IntN(len(heads))]
character.headMesh, appearance.Race = head.Mesh, head.Race
character.appearance = appearance.packed()
- if err := server.saveUser_locked(character); err != nil {
+ if err := server.saveVisitor_locked(character); err != nil {
delete(server.characters, character.id)
server.nextCharacter--
http.Error(w, err.Error(), http.StatusInternalServerError)
diff --git a/server/browser_launch_test.go b/server/browser_launch_test.go
@@ -7,6 +7,7 @@ import (
"net/http"
"net/http/httptest"
"os"
+ "regexp"
"testing"
)
@@ -42,7 +43,7 @@ func TestBrowserLaunchCreatesPersistentVisitor(t *testing.T) {
t.Fatalf("saved first character: %+v", loaded.characters[1])
}
visitor := loaded.characters[1]
- if visitor.name != "Visitor1" {
+ if !regexp.MustCompile(`^[A-Z][a-z]{5,7}$`).MatchString(visitor.name) || visitor.name != world.characters[1].name {
t.Fatalf("visitor name is not usable in tell commands: %q", visitor.name)
}
if !visitor.running {
@@ -100,7 +101,7 @@ func TestBrowserLaunchResumesOwnedCharacterAfterRestart(t *testing.T) {
loaded.browserLaunch(response, request)
- if response.Code != http.StatusOK || response.Body.String() != first.Body.String() || len(loaded.characters) != 1 || loaded.characters[1].name != "Visitor1" {
+ if response.Code != http.StatusOK || response.Body.String() != first.Body.String() || len(loaded.characters) != 1 || loaded.characters[1].name != world.characters[1].name {
t.Fatalf("launch response: %d %q", response.Code, response.Body.String())
}
}
diff --git a/server/browser_password_test.go b/server/browser_password_test.go
@@ -37,7 +37,7 @@ func TestBrowserPasswordChangePreservesSessionAndSurvivesRestart(t *testing.T) {
}
// A submitted name must never select a different account.
- response := accountRequest(world, cookie, "password", "Visitor1", newPassword)
+ response := accountRequest(world, cookie, "password", world.characters[1].name, newPassword)
if response.Code != http.StatusNoContent || len(response.Result().Cookies()) != 0 || response.Header().Get("Cache-Control") != "no-store" ||
!reflect.DeepEqual(before, *world.characters[id]) || world.clients[id] != client || !client.ready || len(conn.packets) != 0 {
diff --git a/server/visitor_names.go b/server/visitor_names.go
@@ -0,0 +1,97 @@
+package main
+
+import (
+ "errors"
+ "math/rand/v2"
+ "strings"
+
+ "github.com/mattn/go-sqlite3"
+)
+
+// CV/CCV beginnings, CV middles and CV/CVC endings keep names at 6-8 letters.
+var visitorNameParts = [3][]string{
+ strings.Fields(`
+ ba be bi bo bu ca ce ci co cu da de di do du fa fe fi fo fu
+ ga ge gi go gu ha he hi ho hu ja je ji jo ju ka ke ki ko ku
+ la le li lo lu ma me mi mo mu na ne ni no nu pa pe pi po pu
+ ra re ri ro ru sa se si so su ta te ti to tu va ve vi vo vu
+ wa we wi wo wu za ze zi zo zu
+ bla ble bli blo blu bra bre bri bro bru cla cle cli clo clu
+ cra cre cri cro cru dra dre dri dro dru fla fle fli flo flu
+ fra fre fri fro fru gla gle gli glo glu gra gre gri gro gru
+ pla ple pli plo plu pra pre pri pro pru sla sle sli slo slu
+ sna sne sni sno snu sta ste sti sto stu tra tre tri tro tru`),
+ strings.Fields(`
+ ba be bi bo bu da de di do du fa fe fi fo fu ga ge gi go gu
+ ja je ji jo ju ka ke ki ko ku la le li lo lu ma me mi mo mu
+ na ne ni no nu pa pe pi po pu ra re ri ro ru sa se si so su
+ ta te ti to tu va ve vi vo vu za ze zi zo zu`),
+ strings.Fields(`
+ ba be bi bo bu ban ben bin bon bun bal bel bil bol bul bam bem bim bom bum
+ da de di do du dan den din don dun dal del dil dol dul dam dem dim dom dum
+ fa fe fi fo fu fan fen fin fon fun fal fel fil fol ful fam fem fim fom fum
+ ga ge gi go gu gan gen gin gon gun gal gel gil gol gul gam gem gim gom gum
+ ja je ji jo ju jan jen jin jon jun jal jel jil jol jul jam jem jim jom jum
+ ka ke ki ko ku kan ken kin kon kun kal kel kil kol kul kam kem kim kom kum
+ la le li lo lu lan len lin lon lun lal lel lil lol lul lam lem lim lom lum
+ ma me mi mo mu man men min mon mun mal mel mil mol mul mam mem mim mom mum
+ na ne ni no nu nan nen nin non nun nal nel nil nol nul nam nem nim nom num
+ pa pe pi po pu pan pen pin pon pun pal pel pil pol pul pam pem pim pom pum
+ ra re ri ro ru ran ren rin ron run ral rel ril rol rul ram rem rim rom rum
+ sa se si so su san sen sin son sun sal sel sil sol sul sam sem sim som sum
+ ta te ti to tu tan ten tin ton tun tal tel til tol tul tam tem tim tom tum
+ va ve vi vo vu van ven vin von vun val vel vil vol vul vam vem vim vom vum
+ za ze zi zo zu zan zen zin zon zun zal zel zil zol zul zam zem zim zom zum`),
+}
+
+var visitorNameRoll = rand.IntN
+
+func usableVisitorName(name string) bool {
+ // Reject recognizable profanity and slurs, including across syllable boundaries.
+ for _, word := range []string{
+ "anal", "anus", "boob", "bum", "caca", "coc", "cok", "cum", "dic", "dik", "dudu",
+ "fag", "flab", "fuc", "fuk", "jiz", "kaka", "kik", "kum", "nazi", "neg", "nig",
+ "paki", "penis", "pipi", "pupu", "pus", "rape", "retard", "slag", "slob", "slum",
+ "slur", "slut", "snob", "spic", "stab", "tit", "vagi",
+ } {
+ if strings.Contains(name, word) {
+ return false
+ }
+ }
+ return true
+}
+
+func randomVisitorName() string {
+ for {
+ name := visitorNameParts[0][visitorNameRoll(len(visitorNameParts[0]))] +
+ visitorNameParts[1][visitorNameRoll(len(visitorNameParts[1]))] +
+ visitorNameParts[2][visitorNameRoll(len(visitorNameParts[2]))]
+ if usableVisitorName(name) {
+ return strings.ToUpper(name[:1]) + name[1:]
+ }
+ }
+}
+
+func (server *server) saveVisitor_locked(player *character) error {
+ db, err := server.database()
+ if err != nil {
+ return err
+ }
+ for {
+ player.name = randomVisitorName()
+ var exists bool
+ if err := db.QueryRow("SELECT EXISTS(SELECT 1 FROM characters WHERE id<1000000 AND name=? COLLATE NOCASE)", player.name).Scan(&exists); err != nil {
+ return err
+ }
+ if exists {
+ continue
+ }
+ // The index also protects against a competing database writer after the check.
+ err := server.saveUser_locked(player)
+ var constraint sqlite3.Error
+ if errors.As(err, &constraint) && constraint.ExtendedCode == sqlite3.ErrConstraintUnique {
+ continue
+ }
+ return err
+ }
+}
diff --git a/server/visitor_names_test.go b/server/visitor_names_test.go
@@ -0,0 +1,176 @@
+package main
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "slices"
+ "strings"
+ "testing"
+)
+
+func TestVisitorNamePoolDistinctCapacity(t *testing.T) {
+ // Unique parts, prefix-free beginnings and fixed middles prove unique names.
+ for position, parts := range visitorNameParts {
+ seen := make(map[string]bool)
+ for _, part := range parts {
+ if seen[part] || len(part) < 2 || len(part) > 3 || position == 1 && len(part) != 2 {
+ t.Fatal("ambiguous syllable", position, part)
+ }
+ for _, letter := range part {
+ if letter < 'a' || letter > 'z' {
+ t.Fatal("non-ASCII syllable", part)
+ }
+ }
+ seen[part] = true
+ }
+ }
+ for _, first := range visitorNameParts[0] {
+ for _, second := range visitorNameParts[0] {
+ if first != second && strings.HasPrefix(second, first) {
+ t.Fatal("beginning is not prefix-free", first, second)
+ }
+ }
+ }
+
+ // Count the actual usable pool after filtering, without storing millions of names.
+ var counts [3]int
+ for _, beginning := range visitorNameParts[0] {
+ for _, middle := range visitorNameParts[1] {
+ for _, ending := range visitorNameParts[2] {
+ name := beginning + middle + ending
+ if len(name) < 6 || len(name) > 8 {
+ t.Fatal("name outside the intended length", name)
+ }
+ if usableVisitorName(name) {
+ counts[len(name)-6]++
+ }
+ }
+ }
+ }
+ if counts != [3]int{494983, 1882830, 1224905} {
+ t.Fatal("usable distinct capacity changed", counts)
+ }
+}
+
+func TestRandomVisitorNameRejectsCrossSyllableWords(t *testing.T) {
+ original := visitorNameRoll
+ t.Cleanup(func() { visitorNameRoll = original })
+ rolls := []int{slices.Index(visitorNameParts[0], "tri"), slices.Index(visitorNameParts[1], "ji"), slices.Index(visitorNameParts[2], "ze"), 0, 0, 0}
+ calls := 0
+ visitorNameRoll = func(bound int) int {
+ value := rolls[calls]
+ calls++
+ if value < 0 || value >= bound {
+ t.Fatal("missing sample syllable")
+ }
+ return value
+ }
+
+ name := randomVisitorName()
+
+ if name != "Bababa" || calls != 6 {
+ t.Fatal("blocked combination was not retried", name, calls)
+ }
+}
+
+func TestBrowserLaunchRetriesCaseInsensitiveNameCollision(t *testing.T) {
+ world := newTestServer(t)
+ existing := world.newCharacter()
+ profile := existing.userData()
+ profile.Name = "bAbAbA"
+ if err := world.updateUser(profile); err != nil {
+ t.Fatal(err)
+ }
+ original := visitorNameRoll
+ t.Cleanup(func() { visitorNameRoll = original })
+ calls := 0
+ visitorNameRoll = func(int) int {
+ calls++
+ if calls == 6 {
+ return 1
+ }
+ return 0
+ }
+ response := httptest.NewRecorder()
+
+ world.browserLaunch(response, httptest.NewRequest("POST", "/browser-launch", nil))
+
+ if response.Code != http.StatusOK || world.characters[2].name != "Bababe" || calls != 6 || existing.name != "bAbAbA" {
+ t.Fatal("visitor collision changed an existing character or skipped retry", response.Code, calls)
+ }
+ // The database protects unclaimed names too; repeated NPC names remain valid.
+ if _, err := world.db.Exec("UPDATE characters SET name='BABABE' WHERE id=1"); err == nil {
+ t.Fatal("database accepted a case-insensitive duplicate visitor name")
+ }
+ if _, err := world.db.Exec("INSERT INTO characters(id,name) VALUES (4294967294,'Bababe'),(4294967295,'Bababe')"); err != nil {
+ t.Fatal("player name constraint affected NPCs", err)
+ }
+}
+
+func TestBrowserLaunchConcurrentNamesStayUnique(t *testing.T) {
+ world := newTestServer(t)
+ responses := make(chan *httptest.ResponseRecorder, 32)
+ for range 32 {
+ go func() {
+ response := httptest.NewRecorder()
+ world.browserLaunch(response, httptest.NewRequest("POST", "/browser-launch", nil))
+ responses <- response
+ }()
+ }
+ for range 32 {
+ response := <-responses
+ if response.Code != http.StatusOK || len(response.Result().Cookies()) != 1 {
+ t.Error("concurrent visitor launch failed", response.Code, response.Body)
+ }
+ }
+
+ var players, names int
+ if err := world.db.QueryRow("SELECT count(*),count(DISTINCT name COLLATE NOCASE) FROM characters WHERE id<1000000").Scan(&players, &names); err != nil {
+ t.Fatal(err)
+ }
+ if players != 32 || names != 32 || world.nextCharacter != 32 {
+ t.Fatal("concurrent launches reused a name or identity", players, names, world.nextCharacter)
+ }
+}
+
+func TestBrowserVisitorCanAdoptItsGeneratedName(t *testing.T) {
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ name := world.characters[1].name
+
+ claimed := accountRequest(world, cookie, "claim", name, "password")
+ if claimed.Code != http.StatusNoContent {
+ t.Fatal("generated name could not be kept", claimed.Code, claimed.Body)
+ }
+ request := httptest.NewRequest("GET", "/browser-account", nil)
+ request.AddCookie(claimed.Result().Cookies()[0])
+ response := httptest.NewRecorder()
+ world.browserAccountInfo(response, request)
+
+ var state struct {
+ Name string
+ Visitor, Adopted bool
+ }
+ if err := json.Unmarshal(response.Body.Bytes(), &state); err != nil || state.Name != name || state.Visitor || !state.Adopted {
+ t.Fatal("adoption depended on the name spelling", response.Body, err)
+ }
+}
+
+func TestBrowserLaunchFailedSaveDoesNotPublishVisitor(t *testing.T) {
+ world := newTestServer(t)
+ if _, err := world.db.Exec("CREATE TRIGGER reject_visitor BEFORE INSERT ON characters WHEN NEW.id<1000000 BEGIN SELECT RAISE(ABORT,'refuse visitor'); END"); err != nil {
+ t.Fatal(err)
+ }
+ response := httptest.NewRecorder()
+
+ world.browserLaunch(response, httptest.NewRequest("POST", "/browser-launch", nil))
+
+ var players int
+ if err := world.db.QueryRow("SELECT count(*) FROM characters WHERE id<1000000").Scan(&players); err != nil {
+ t.Fatal(err)
+ }
+ if response.Code != http.StatusInternalServerError || len(response.Result().Cookies()) != 0 || world.nextCharacter != 0 || world.characters[1] != nil || players != 0 {
+ t.Fatal("failed save published a visitor", response.Code, world.nextCharacter, players)
+ }
+}
diff --git a/server/world.sql b/server/world.sql
@@ -127,7 +127,7 @@ CREATE TABLE IF NOT EXISTS characters (
regeneration_seconds INTEGER NOT NULL DEFAULT 0,
resurrection_shock INTEGER NOT NULL DEFAULT 0
);
-CREATE UNIQUE INDEX IF NOT EXISTS player_login_names ON characters(name COLLATE NOCASE) WHERE length(password_hash)>0;
+CREATE UNIQUE INDEX IF NOT EXISTS player_names ON characters(name COLLATE NOCASE) WHERE id<1000000;
CREATE TABLE IF NOT EXISTS players (
id INTEGER PRIMARY KEY REFERENCES characters(id) ON DELETE CASCADE CHECK (id BETWEEN 1 AND 999999),
last_ip TEXT NOT NULL DEFAULT '',