[Scummvm-devel] [Scummvm-cvs-logs] SF.net SVN: scummvm:[51435] scummvm/trunk/engines/sci/engine

Johannes Schickel lordhoto at gmail.com
Thu Jul 29 00:26:22 CEST 2010


On Wed, Jul 28, 2010 at 11:47 PM,  <m_kiewitz at users.sourceforge.net> wrote:
> Revision: 51435
>          http://scummvm.svn.sourceforge.net/scummvm/?rev=51435&view=rev
> Author:   m_kiewitz
> Date:     2010-07-28 21:47:15 +0000 (Wed, 28 Jul 2010)
>
> Log Message:
> -----------
> SCI: implement additional variants of kRandom
>
> fixes pq1vga poker game (bug #3036125)

Hi,

is there any special reason to use rand here? And not a
Common::RandomSource object (of course that should not only be used
locally)? If we really want to use our event recording for automatic
testing in the future we must be sure that the random numbers used in
the replay run are the same as in the original run. When using
Common::RandomSource that is assured (as long as it is registered
properly and some other conditions like no new code paths introduced
which use random numbers). For rand we can not assure that anyhow,
since for example different libc implementations might used different
generators, thus they might produce different numbers even with the
same seed.

// Johannes

>
> Modified Paths:
> --------------
>    scummvm/trunk/engines/sci/engine/kernel_tables.h
>    scummvm/trunk/engines/sci/engine/kmath.cpp
>
> Modified: scummvm/trunk/engines/sci/engine/kernel_tables.h
> ===================================================================
> --- scummvm/trunk/engines/sci/engine/kernel_tables.h    2010-07-28 21:40:47 UTC (rev 51434)
> +++ scummvm/trunk/engines/sci/engine/kernel_tables.h    2010-07-28 21:47:15 UTC (rev 51435)
> @@ -407,6 +407,8 @@
>     { MAP_CALL(Portrait),          SIG_EVERYWHERE,           "i(.*)",                 NULL,            NULL }, // subop
>     { MAP_CALL(PrevNode),          SIG_EVERYWHERE,           "n",                     NULL,            NULL },
>     { MAP_CALL(PriCoord),          SIG_EVERYWHERE,           "i",                     NULL,            NULL },
> +    { MAP_CALL(Random),            SIG_SCI11, SIGFOR_ALL,    "i(i)(i)",               NULL,            NULL },
> +    // ^^ they actually changed it in SCI1, but it seems its never called that way ffs. kRandom
>     { MAP_CALL(Random),            SIG_EVERYWHERE,           "ii",                    NULL,            NULL },
>     { MAP_CALL(ReadNumber),        SIG_EVERYWHERE,           "r",                     NULL,            NULL },
>     { MAP_CALL(ResCheck),          SIG_EVERYWHERE,           "ii(iiii)",              NULL,            NULL },
>
> Modified: scummvm/trunk/engines/sci/engine/kmath.cpp
> ===================================================================
> --- scummvm/trunk/engines/sci/engine/kmath.cpp  2010-07-28 21:40:47 UTC (rev 51434)
> +++ scummvm/trunk/engines/sci/engine/kmath.cpp  2010-07-28 21:47:15 UTC (rev 51435)
> @@ -29,10 +29,27 @@
>  namespace Sci {
>
>  reg_t kRandom(EngineState *s, int argc, reg_t *argv) {
> -       int fromNumber = argv[0].toUint16();
> -       int toNumber = argv[1].toUint16();
> -       double randomNumber = fromNumber + ((toNumber + 1.0 - fromNumber) * (rand() / (RAND_MAX + 1.0)));
> -       return make_reg(0, (int)randomNumber);
> +       // SCI1 actually supported those argcs as well
> +       // SCI0 only supported argc = 1 to reset the seed (no input was used, it was reset to 0)
> +       switch (argc) {
> +       case 1: // set seed to argv[0]
> +               return NULL_REG;
> +
> +       case 2: { // get random number
> +               int fromNumber = argv[0].toUint16();
> +               int toNumber = argv[1].toUint16();
> +               double randomNumber = fromNumber + ((toNumber + 1.0 - fromNumber) * (rand() / (RAND_MAX + 1.0)));
> +               return make_reg(0, (int)randomNumber);
> +       }
> +
> +       case 3: // get seed
> +               // Actually we would have to return the previous seed
> +               error("kRandom: scripts asked for previous seed");
> +               break;
> +
> +       default:
> +               error("kRandom: unsupported argc");
> +       }
>  }
>
>  reg_t kAbs(EngineState *s, int argc, reg_t *argv) {
>
>
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://p.sf.net/sfu/dev2dev-palm
> _______________________________________________
> Scummvm-cvs-logs mailing list
> Scummvm-cvs-logs at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scummvm-cvs-logs
>




More information about the Scummvm-devel mailing list