function newIsland($hako, $data) { global $init; $log = new Log(); if ($hako->islandNumber >= $init->maxIsland) { HakoError::newIslandFull(); return; } if (empty($data['ISLANDNAME'])) { HakoError::newIslandNoName(); return; } // 名前が正当化チェック if (preg_match("/[,?()<>\$]/", $data['ISLANDNAME']) || strcmp($data['ISLANDNAME'], "無人") == 0) { HakoError::newIslandBadName(); return; } // 名前の重複チェック if (Util::nameToNumber($hako, $data['ISLANDNAME']) != -1) { HakoError::newIslandAlready(); return; } // パスワードの存在判定 if (empty($data['PASSWORD'])) { HakoError::newIslandNoPassword(); return; } if (strcmp($data['PASSWORD'], $data['PASSWORD2']) != 0) { HakoError::wrongPassword(); return; } // 新しい島の番号を決める $newNumber = $hako->islandNumber; $hako->islandNumber++; $hako->islandNumberNoBF++; $hako->islandNumberNoKP++; $island = $this->makeNewIsland(); // 島の番号の使いまわし $safety = 0; while (isset($hako->idToNumber[$hako->islandNextID])) { $hako->islandNextID++; if ($hako->islandNextID > 250) { $hako->islandNextID = 1; } $safety++; if ($safety == 250) { break; } } // 各種の値を設定 $island['name'] = htmlspecialchars($data['ISLANDNAME']); $island['owner'] = htmlspecialchars($data['OWNERNAME']); $island['id'] = $hako->islandNextID; $hako->islandNextID++; $island['starturn'] = $hako->islandTurn; $island['isBF'] = $island['keep'] = 0; $island['absent'] = $init->giveupTurn - 3; $island['comment'] = '(未登録)'; $island['comment_turn'] = $hako->islandTurn; $island['password'] = Util::encode($data['PASSWORD']); $island['tenki'] = 1; $island['team'] = $island['shiai'] = $island['kachi'] = $island['make'] = $island['hikiwake'] = $island['kougeki'] = $island['bougyo'] = $island['tokuten'] = $island['shitten'] = 0; Turn::estimate($hako, $island); if ($hako->islandNumberBF > 0) { for ($i = 0; $i < $hako->islandNumberBF; $i++) { $hako->islands[$newNumber - $i] = $hako->islands[$newNumber - $i - 1]; } $hako->islands[$newNumber - $hako->islandNumberBF] = $island; } else { $hako->islands[$newNumber] = $island; } $hako->writeIslandsFile($island['id']); $log->discover($island['id'], $island['name']); $htmlMap = new HtmlMap(); $htmlMap->newIslandHead($island['name']); $htmlMap->islandInfo($island, $newNumber); $htmlMap->islandMap($hako, $island, 1, $data); }