Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ManRNG - a cross-platform command-line RNG generator for Pokémon games
- (c) M.andrew 2012
- This utility provides the user with access to the full range of RNG
- operations available in the popular Pokémon series of games, allowing
- him to find shiny and/or flawless Pokémon no matter what type of computer
- he is using. By default, positive results are send to stdout in CSV format,
- allowing them to be easily piped into bash text manipulation utilities
- or simply saved directly into text files.
- The ultimate goal of this program is to match the seed-generation capabilities
- of the widely-known RNG Reporter utility for Windows while supporting all
- of its major file formats, including the XML profiles of the alpha-stage
- RNGR 9.96. Once this goal is realized and a standarized format for args
- is set in place, I foresee writing frontends for the program to improve
- its ease of use for the public.
- */
- #include <stdio.h>
- #include <cstdlib>
- #include <iostream>
- #include "researcher.h"
- #include "thirdgen.h"
- #include "fourthgen.h"
- #include "fifthgen.h"
- enum ERROR_CODES {
- ERR_NOARGS = 1,
- ERR_NOMETHOD,
- ERR_FALSEARGS,
- ERR_3GNOSUPPORT,
- ERR_4GNOSUPPORT,
- ERR_5GNOSUPPORT,
- };
- int MethodLen (char* Method) {
- int counter = 0;
- do
- {
- counter++=Method++;
- }
- while (Method != NULL)
- return counter;
- }
- char RNGMethodHandler(int Generation, char* Method)
- {
- char MethodSwitch;
- int ArgLen = MethodLen(Method);
- if (ArgLen < 2)
- {
- fprintf(stderr,"Method string must be at least 2 chars!");
- exit(ERR_NOMETHOD);
- }
- else if (ArgLen == 2)
- {
- MethodSwitch = Method[1];
- }
- char LongOpSwitch = Method[1]++;
- if (LongOpSwitch == '-')
- {
- // we're using longops here. we're going to convert
- // them into single-char options and let them
- // gracefully descend through the control flow
- // options supported:
- // -t [--timefinder]
- // -p [--pandora]
- // -v [--pidfromivs]
- // -c [--chainsidfinder]
- // -m [--seed2time]
- // -r [--parameters]
- char* LongOpName = new char[ArgLen-2];
- for (int i = 0, i >= ArgLen-2, i++)
- {
- LongOpName[i] = Method[i+2];
- }
- if (LongOpName == "timefinder") { MethodSwitch = 't'; }
- else if (LongOpName == "pandora") { MethodSwitch = 'p'; }
- else if (LongOpName == "pidfromivs") { MethodSwitch = 'v'; }
- else if (LongOpName == "chainsidfinder") { MethodSwitch = 'c'; }
- else if (LongOpName == "seed2time") { MethodSwitch = 'm'; }
- else if (LongOpName == "parameters") { MethodSwitch = 'r'; }
- else
- {
- fprintf(stderr,"Long method name unrecognized!")
- exit(ERR_NOMETHOD);
- }
- }
- switch (Generation)
- {
- case 3:
- // options supported:
- // -t [--timefinder]
- // -p [--pandora]
- switch (MethodSwitch)
- {
- case 't':
- TimeFinderThird();
- break;
- case 'p':
- PandoraThird();
- break;
- default:
- fprintf(stderr,"Unsupported method for third generation RNG.");
- exit(ERR_3GNOSUPPORT);
- }
- case 4:
- // options supported:
- // -t [--timefinder]
- // -v [--pidfromivs]
- // -c [--chainsidfinder]
- // -m [--seed2time]
- // -p [--pandora]
- switch (MethodSwitch)
- {
- case 't':
- TimeFinderFourth();
- break;
- case 'v':
- PidFromIVsFourth();
- break;
- case 'c':
- ChainSIDFinderFourth();
- break;
- case 'm':
- Seed2TimeFourth();
- break;
- case 'p':
- PandoraFourth();
- break;
- default:
- fprintf(stderr,"Unsupported method for fourth generation RNG.");
- exit(ERR_5GNOSUPPORT);
- }
- case 5:
- // options supported:
- // -t [--timefinder]
- // -r [--parameters]
- // -m [--seed2time] (c-gear)
- // -p [--pandora]
- switch (MethodSwitch)
- {
- case 't':
- TimeFinderFifth();
- break;
- case 'r':
- ParamSearchFifth();
- break;
- case 'm':
- Seed2TimeFifth();
- break;
- case 'p':
- PandoraFifth();
- break;
- default:
- fprintf(stderr,"Unsupported method for fifth generation RNG.");
- exit(ERR_5GNOSUPPORT);
- }
- }
- return 0;
- }
- int main(int argc, char* argv[])
- {
- if (argv[1] == NULL)
- {
- fprintf(stderr,"ManRNG cannot function without any arguments!");
- exit(ERR_NOARGS);
- }
- char GenFlag = argv[1][1]; //this should be a 3, 4, or 5
- char* MethodSearch;
- if (GenFlag == '3' || GenFlag == '4' || GenFlag == '5')
- {
- MethodSearch = argv[2];
- if (MethodSearch == "")
- {
- fprintf(stderr,"ManRNG requires a method as its second argument.");
- exit(ERR_NOMETHOD);
- }
- RNGMethodHandler(static_cast<int>(GenFlag),MethodSearch);
- }
- else if (GenFlag == 'r')
- {
- Researcher();
- }
- else
- {
- fprintf(stderr,"ManRNG requires -3, -4, -5, or -r as its first argument.");
- exit(ERR_FALSEARGS);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment