Ejemplo n.º 1
0
void ConfigManager::loadEnabledZones() {
	enabledZones.removeAll();

	LuaObject zones = getGlobalObject("ZonesEnabled");

	for (int i = 1; i <= zones.getTableSize(); ++i)
		enabledZones.put(zones.getStringAt(i));

	zones.pop();
}
Ejemplo n.º 2
0
void SchematicMap::loadDraftSchematicFile() {
	runFile("scripts/managers/crafting/schematics.lua");

	// Read and create all the items in the config unless they
	// were already loaded from database.

	LuaObject serverScriptCRCList = getGlobalObject("schematics");

	int size = serverScriptCRCList.getTableSize();
	int count = 0;

	lua_State* L = serverScriptCRCList.getLuaState();

	for (int i = 0; i < size; ++i) {

		lua_rawgeti(L, -1, i + 1);
		LuaObject luaObject(L);

		String path = luaObject.getStringField("path");
		uint32 servercrc = path.hashCode();

		Reference<DraftSchematic*> schematic = schematicCrcMap.get(servercrc);

		luaObject.pop();

		if (schematic == NULL) {
			try {
				schematic = dynamic_cast<DraftSchematic*> (objectManager->createObject(servercrc, 1, "draftschematics"));

				if(schematic == NULL) {
					error("Could not create schematic with crc: " + String::valueOf(servercrc));
					continue;
				}

			} catch (Exception& e) {
				error(e.getMessage());
				error("Could not create schematic with template: " + path);
				continue;
			}
			if(!schematicCrcMap.contains(schematic->getServerObjectCRC()))
				schematicCrcMap.put(schematic->getServerObjectCRC(), schematic);

			if(!schematicCrcMap.contains(schematic->getClientObjectCRC()))
				schematicCrcMap.put(schematic->getClientObjectCRC(), schematic);

			count++;

		}
	}

	info("Loaded " + String::valueOf(count) + " schematics from scripts", true);

	serverScriptCRCList.pop();
}
Ejemplo n.º 3
0
void ConfigManager::loadTreFileList() {
	treFiles.removeAll();

	LuaObject files = getGlobalObject("TreFiles");

	for (int i = 1; i <= files.getTableSize(); ++i) {
		treFiles.add(files.getStringAt(i));
	}

	files.pop();
}
Ejemplo n.º 4
0
V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int worldId)
    : m_world(DOMWrapperWorld::create(worldId)),
      m_frame(proxy->frame())
{
    v8::HandleScope scope;
    v8::Handle<v8::Context> mainWorldContext = proxy->windowShell()->context();
    if (mainWorldContext.IsEmpty())
        return;

    // FIXME: We should be creating a new V8DOMWindowShell here instead of riping out the context.
    m_context = SharedPersistent<v8::Context>::create(proxy->windowShell()->createNewContext(v8::Handle<v8::Object>(), extensionGroup, m_world->worldId()));
    if (m_context->get().IsEmpty())
        return;

    // Run code in the new context.
    v8::Context::Scope contextScope(m_context->get());

    // Setup context id for JS debugger.
    setInjectedScriptContextDebugId(m_context->get(), proxy->contextDebugId(mainWorldContext));

    getGlobalObject(m_context->get())->SetPointerInInternalField(V8DOMWindow::enteredIsolatedWorldIndex, this);

    m_perContextData = V8PerContextData::create(m_context->get());
    m_perContextData->init();

    // FIXME: This will go away once we have a windowShell for the isolated world.
    proxy->windowShell()->installDOMWindow(m_context->get(), m_frame->document()->domWindow());

    // Using the default security token means that the canAccess is always
    // called, which is slow.
    // FIXME: Use tokens where possible. This will mean keeping track of all
    //        created contexts so that they can all be updated when the
    //        document domain
    //        changes.
    m_context->get()->UseDefaultSecurityToken();

    m_frame->loader()->client()->didCreateScriptContext(context(), extensionGroup, m_world->worldId());
}
Ejemplo n.º 5
0
V8IsolatedContext* V8IsolatedContext::isolatedContext()
{
    return reinterpret_cast<V8IsolatedContext*>(getGlobalObject(v8::Context::GetEntered())->GetPointerFromInternalField(V8DOMWindow::enteredIsolatedWorldIndex));
}