Daniele Bartolini 10 лет назад
Родитель
Сommit
f010818c2d
4 измененных файлов с 10 добавлено и 17 удалено
  1. 1 1
      src/console_server.cpp
  2. 4 10
      src/device.cpp
  3. 3 4
      src/device.h
  4. 2 2
      src/lua/lua_device.cpp

+ 1 - 1
src/console_server.cpp

@@ -195,7 +195,7 @@ void ConsoleServer::process_command(TCPSocket /*client*/, const char* json)
 		json::parse_string(root["resource_type"], type);
 		json::parse_string(root["resource_name"], name);
 
-		device()->reload(type.c_str(), name.c_str());
+		device()->reload(StringId64(type.c_str()), StringId64(name.c_str()));
 	}
 	else if (cmd == "pause")
 	{

+ 4 - 10
src/device.cpp

@@ -82,7 +82,7 @@ void Device::shutdown()
 	_lua_environment->call_global("shutdown", 0);
 
 	_boot_package->unload();
-	destroy_resource_package(_boot_package);
+	destroy_resource_package(*_boot_package);
 
 	CE_DELETE(_allocator, _lua_environment);
 
@@ -193,23 +193,17 @@ void Device::destroy_world(World& w)
 	CE_ASSERT(false, "Bad world");
 }
 
-ResourcePackage* Device::create_resource_package(const char* name)
-{
-	ResourceId resid("package", name);
-	return create_resource_package((StringId64) resid.name);
-}
-
 ResourcePackage* Device::create_resource_package(StringId64 id)
 {
 	return CE_NEW(default_allocator(), ResourcePackage)(id, *_resource_manager);
 }
 
-void Device::destroy_resource_package(ResourcePackage* package)
+void Device::destroy_resource_package(ResourcePackage& package)
 {
-	CE_DELETE(default_allocator(), package);
+	CE_DELETE(default_allocator(), &package);
 }
 
-void Device::reload(const char* , const char* )
+void Device::reload(StringId64 type, StringId64 name)
 {
 }
 

+ 3 - 4
src/device.h

@@ -90,17 +90,16 @@ struct Device
 	/// Destroys the given @a world.
 	void destroy_world(World& w);
 
-	/// Returns the resource package with the given @a package_name name.
-	ResourcePackage* create_resource_package(const char* name);
+	/// Returns the resource package @a id.
 	ResourcePackage* create_resource_package(StringId64 id);
 
 	/// Destroy a previously created resource @a package.
 	/// @note
 	/// To unload the resources loaded by the package, you have to call
 	/// ResourcePackage::unload() first.
-	void destroy_resource_package(ResourcePackage* package);
+	void destroy_resource_package(ResourcePackage& package);
 
-	void reload(const char* type, const char* name);
+	void reload(StringId64 type, StringId64 name);
 
 	ResourceManager* resource_manager();
 	LuaEnvironment* lua_environment();

+ 2 - 2
src/lua/lua_device.cpp

@@ -85,14 +85,14 @@ static int device_render_world(lua_State* L)
 static int device_create_resource_package(lua_State* L)
 {
 	LuaStack stack(L);
-	stack.push_resource_package(device()->create_resource_package(stack.get_string(1)));
+	stack.push_resource_package(device()->create_resource_package(stack.get_resource_id(1)));
 	return 1;
 }
 
 static int device_destroy_resource_package(lua_State* L)
 {
 	LuaStack stack(L);
-	device()->destroy_resource_package(stack.get_resource_package(1));
+	device()->destroy_resource_package(*stack.get_resource_package(1));
 	return 0;
 }