[mythtv] Hacking on gamehandler.cpp in mythgame

Espen A. Fossen espenaf at junta.no
Sun May 16 09:45:48 UTC 2010


Hi

I've been trying to fix a spandisk issue in the UpdateGameCounts method
in gamehandler.cpp, but it isn't working. The current version uses an
regex to match for disk number at the end of a string after removeing
the extension, like this:

 QRegExp multiDiskRGXP = QRegExp( "[0-4]$", Qt::CaseSensitive,
QRegExp::RegExp);

I have some Amiga games with more than 4 disks, so compensate for the
number of disks in edited the regex to handle up to 9 disks, like this.

 QRegExp multiDiskRGXP = QRegExp( "[0-9]$", Qt::CaseSensitive,
QRegExp::RegExp);

This is working out good, giving me this in the gamemetadata

+---------------------------+----------------------+-----------+
| romname                   | gamename             | diskcount |
+---------------------------+----------------------+-----------+
| Perihelion.1.zip          | Perihelion           |         5 |
| Perihelion.2.zip          | Perihelion           |         1 |
| Perihelion.3.zip          | Perihelion           |         1 |
| Perihelion.4.zip          | Perihelion           |         1 |
| Perihelion.5.zip          | Perihelion           |         1 |
| Rise of the Dragon.1.zip  | Rise of the Dragon   |         1 |
| Rise of the Dragon.10.zip | Rise of the Dragon.1 |         1 |
| Rise of the Dragon.2.zip  | Rise of the Dragon   |         8 |
| Rise of the Dragon.3.zip  | Rise of the Dragon   |         1 |
| Rise of the Dragon.4.zip  | Rise of the Dragon   |         1 |
| Rise of the Dragon.5.zip  | Rise of the Dragon   |         1 |
| Rise of the Dragon.6.zip  | Rise of the Dragon   |         1 |
| Rise of the Dragon.7.zip  | Rise of the Dragon   |         1 |
| Rise of the Dragon.8.zip  | Rise of the Dragon   |         1 |
| Rise of the Dragon.9.zip  | Rise of the Dragon   |         1 |
+---------------------------+----------------------+-----------+

But as you see this isn't working for games with more than 9 disks. So
i've tried to solve that as well, but C isn't my strongest side. To
match disks with number 10->99, I used;

 QRegExp multiDiskRGXP2 = QRegExp( "[0-9]{2}$", Qt::CaseSensitive,
QRegExp::RegExp);

Then make a check for this before checking for romname with 1 digit
ending. The actual code looks like this:

----
                        pos = RomName.lastIndexOf(".");
                        if (pos > 1)
                        {
                            extlength = RomName.length() - pos;
                            pos--;

                            basename = RomName.mid(pos,1);
                        }

+                       if (basename.contains(multiDiskRGXP2))
+                       {
+                           pos = (RomName.length() - extlength) - 2;
+                           basename = RomName.left(pos);
+
+                           if (basename.right(1) == ".")
+                               basename = RomName.left(pos - 1);
+                       }
                        else if (basename.contains(multiDiskRGXP))
                        {
                            pos = (RomName.length() - extlength) - 1;
                            basename = RomName.left(pos);

                            if (basename.right(1) == ".")
                                basename = RomName.left(pos - 1);
                        }
                        else
                            basename = GameName;
----

The point of the procedure is to get the correct basename, then update
diskcount if it matches. The problem is that it looks like mye regex is
never kicking in, and the result is just like the table above. I'am
pretty sure that regex should match for only 2 digits at the end of an
string.

What I am doing wrong? Could anyone enlighten med before I start
learning how to setup an IDE and debugger.

Espen




More information about the mythtv-dev mailing list