Browse Source

Assert on resource not loaded

Daniele Bartolini 11 năm trước cách đây
mục cha
commit
144b71f08a

+ 2 - 1
engine/resource/resource_id.h

@@ -32,9 +32,10 @@ struct ResourceId
 	{
 	{
 	}
 	}
 
 
-	void to_string(char out[64])
+	const char* to_string(char out[64])
 	{
 	{
 		snprintf(out, 64, "%.16"PRIx64"-%.16"PRIx64, type, name);
 		snprintf(out, 64, "%.16"PRIx64"-%.16"PRIx64, type, name);
+		return out;
 	}
 	}
 
 
 	bool operator==(const ResourceId& a) const
 	bool operator==(const ResourceId& a) const

+ 4 - 0
engine/resource/resource_manager.cpp

@@ -104,6 +104,10 @@ const void* ResourceManager::get(StringId64 type, StringId64 name)
 {
 {
 	ResourceId id(type, name);
 	ResourceId id(type, name);
 
 
+	char buf[64];
+	CE_ASSERT(can_get(type, name), "Resource not loaded #ID(%s)", id.to_string(buf));
+	CE_UNUSED(buf);
+
 	if (_autoload && !sort_map::has(_rm, id))
 	if (_autoload && !sort_map::has(_rm, id))
 	{
 	{
 		load(type, name);
 		load(type, name);