[Scummvm-devel] To all engine maintainers. Detector failure behaviour.

Max Horn max at quendi.de
Wed Apr 26 07:47:06 CEST 2006


Am 26.04.2006 um 16:26 schrieb Eugene Sandulenko:

> On Wed, 26 Apr 2006 09:43:54 +0200
> Max Horn <max at quendi.de> wrote:
>
>> If the engine/plugin fails to find a game, it should not create and
>> return a fake engine object. Rather, Engine_FOO_create() should
>> return one of multiple possible error ids. The error message itself
>> should be displayed by the code which creates the engines, which
>> currently resides in main.cpp.
> That was the first thing which came to my mind, but how would you
> achieve it? If it would be Lisp or even Perl, I'd return multiple
> values.

Yes, you'd return multiple values. Either by returning a "pair", or  
more C/C++ like, by passing values-by-reference / values-by-pointers.

>
> Now you need both Engine instance and error code. How to do that? Pass
> a pointer to error variable?
>
>   int result;
>   Engine *engine = plugin->createInstance(&system, &result);
>   if (!engine) {
>      switch (result) {}
>   }

Actually, I'd make the error code the return value, and the engine  
pointer a parameter:

ErrorCode err = plugin->createInstance(&system, &engine);
switch (err) {
case kNoError:
...
}


This has been on the TODO for quite some time (3rd entry under http:// 
wiki.scummvm.org/index.php/TODO#Plugins), by the way :-).


Cheers,
Max




More information about the Scummvm-devel mailing list