|
@@ -32,6 +32,8 @@ Game::Game(Framework::Text name, Framework::Text worldsDir)
|
|
|
: Thread(),
|
|
|
name(name),
|
|
|
typeRegistry(new TypeRegistry()),
|
|
|
+ blockTypeNameFactory(new BlockTypeNameFactory()),
|
|
|
+ itemTypeNameFactory(new ItemTypeNameFactory()),
|
|
|
dimensions(new RCArray<Dimension>()),
|
|
|
clients(new RCArray<GameClient>()),
|
|
|
questManager(new QuestManager()),
|
|
@@ -60,6 +62,11 @@ Game::Game(Framework::Text name, Framework::Text worldsDir)
|
|
|
multiblockStructureTypes(0),
|
|
|
multiblockStructureTypeCount(0)
|
|
|
{
|
|
|
+ typeRegistry->registerType(
|
|
|
+ BlockTypeNameFactory::TYPE_ID, blockTypeNameFactory);
|
|
|
+ typeRegistry->registerType(
|
|
|
+ ItemTypeNameFactory::TYPE_ID, itemTypeNameFactory);
|
|
|
+
|
|
|
if (!DateiExistiert(path)) DateiPfadErstellen(path + "/");
|
|
|
Datei d;
|
|
|
d.setDatei(path + "/eid");
|
|
@@ -154,10 +161,14 @@ void Game::initialize()
|
|
|
{
|
|
|
blockTypes[blockTypeCount++] = blockType;
|
|
|
}
|
|
|
+ Framework::RCArray<Framework::Text>* blockTypeNames
|
|
|
+ = new Framework::RCArray<Framework::Text>();
|
|
|
for (int i = 0; i < blockTypeCount; i++)
|
|
|
{
|
|
|
+ blockTypeNames->add(new Framework::Text(blockTypes[i]->getName()));
|
|
|
blockTypes[i]->setTypeId(i);
|
|
|
}
|
|
|
+ blockTypeNameFactory->setBlockTypeNames(blockTypeNames);
|
|
|
Framework::Logging::info() << "Loading item types";
|
|
|
Framework::Array<ItemType*> itemTypeArray;
|
|
|
validator
|
|
@@ -210,13 +221,17 @@ void Game::initialize()
|
|
|
{
|
|
|
itemTypes[itemTypeCount++] = itemType;
|
|
|
}
|
|
|
+ Framework::RCArray<Framework::Text>* itemTypeNames
|
|
|
+ = new Framework::RCArray<Framework::Text>();
|
|
|
for (int i = 0; i < itemTypeCount; i++)
|
|
|
{
|
|
|
itemTypes[i]->setTypeId(i);
|
|
|
+ itemTypeNames->add(new Framework::Text(itemTypes[i]->getName()));
|
|
|
}
|
|
|
+ itemTypeNameFactory->setItemTypeNames(itemTypeNames);
|
|
|
Framework::Logging::info() << "Loading entity types";
|
|
|
Framework::Array<EntityType*> entityTypeArray;
|
|
|
- /* validator
|
|
|
+ /*validator
|
|
|
= Framework::JSON::Validator::JSONValidator::buildForArray()
|
|
|
->addAcceptedTypeInArray(typeRegistry->getValidator<EntityType>())
|
|
|
->removeInvalidEntries()
|
|
@@ -328,6 +343,46 @@ void Game::initialize()
|
|
|
// save syntax info
|
|
|
Framework::DateiRemove("data/syntax");
|
|
|
typeRegistry->writeSyntaxInfo("data/syntax");
|
|
|
+
|
|
|
+ validator
|
|
|
+ = Framework::Validator::DataValidator::buildForArray()
|
|
|
+ ->addAcceptedTypeInArray(typeRegistry->getValidator<BlockType>())
|
|
|
+ ->finishArray();
|
|
|
+ Framework::JSON::JSONObject* schema = validator->getJsonSchema();
|
|
|
+ Framework::Datei syntaxFile;
|
|
|
+ syntaxFile.setDatei("data/syntax/schema/blocks.json");
|
|
|
+ syntaxFile.erstellen();
|
|
|
+ syntaxFile.open(Framework::Datei::Style::schreiben);
|
|
|
+ syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
|
|
|
+ syntaxFile.close();
|
|
|
+ schema->release();
|
|
|
+ validator->release();
|
|
|
+
|
|
|
+ validator
|
|
|
+ = Framework::Validator::DataValidator::buildForArray()
|
|
|
+ ->addAcceptedTypeInArray(typeRegistry->getValidator<ItemType>())
|
|
|
+ ->finishArray();
|
|
|
+ schema = validator->getJsonSchema();
|
|
|
+ syntaxFile.setDatei("data/syntax/schema/items.json");
|
|
|
+ syntaxFile.erstellen();
|
|
|
+ syntaxFile.open(Framework::Datei::Style::schreiben);
|
|
|
+ syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
|
|
|
+ syntaxFile.close();
|
|
|
+ schema->release();
|
|
|
+ validator->release();
|
|
|
+ validator
|
|
|
+ = Framework::Validator::DataValidator::buildForArray()
|
|
|
+ ->addAcceptedTypeInArray(typeRegistry->getValidator<EntityType>())
|
|
|
+ ->finishArray();
|
|
|
+ schema = validator->getJsonSchema();
|
|
|
+ syntaxFile.setDatei("data/syntax/schema/entities.json");
|
|
|
+ syntaxFile.erstellen();
|
|
|
+ syntaxFile.open(Framework::Datei::Style::schreiben);
|
|
|
+ syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
|
|
|
+ syntaxFile.close();
|
|
|
+ schema->release();
|
|
|
+ validator->release();
|
|
|
+
|
|
|
// initialize world generator and world loader
|
|
|
int seed = 0;
|
|
|
int index = 0;
|