Changeset - r24497:0c8c1b28cae4
[Not reviewed]
master
0 1 0
Patric Stout - 4 years ago 2020-12-25 13:44:28
truebrain@openttd.org
Codechange: move block a bit lower to increase readability

It was rather confusing that "library_name" was calculated, and
then not used to do the FindLibrary() call. Flipping those two
blocks around makes it a bit more sane to read.
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_controller.cpp
Show inline comments
 
@@ -108,24 +108,24 @@ ScriptController::~ScriptController()
 
/* static */ HSQOBJECT ScriptController::Import(const char *library, const char *class_name, int version)
 
{
 
	ScriptController *controller = ScriptObject::GetActiveInstance()->GetController();
 
	Squirrel *engine = ScriptObject::GetActiveInstance()->engine;
 
	HSQUIRRELVM vm = engine->GetVM();
 

	
 
	/* Internally we store libraries as 'library.version' */
 
	char library_name[1024];
 
	seprintf(library_name, lastof(library_name), "%s.%d", library, version);
 
	strtolower(library_name);
 

	
 
	ScriptInfo *lib = ScriptObject::GetActiveInstance()->FindLibrary(library, version);
 
	if (lib == nullptr) {
 
		char error[1024];
 
		seprintf(error, lastof(error), "couldn't find library '%s' with version %d", library, version);
 
		throw sq_throwerror(vm, error);
 
	}
 

	
 
	/* Internally we store libraries as 'library.version' */
 
	char library_name[1024];
 
	seprintf(library_name, lastof(library_name), "%s.%d", library, version);
 
	strtolower(library_name);
 

	
 
	/* Get the current table/class we belong to */
 
	HSQOBJECT parent;
 
	sq_getstackobj(vm, 1, &parent);
 

	
 
	char fake_class[1024];
 

	
0 comments (0 inline, 0 general)