* Added autocompletion for Pokémon, item, and move names.

* Added the following buttons to the Strategy Memo editor: 'Fill memo' (for both Colosseum and XD) and 'Fill memo (all shiny)' (for Colosseum only) buttons .
 * Stats boosted (resp. hindered) by each nature are now displayed in red (resp. blue).
This commit is contained in:
TuxSH
2015-10-10 20:50:20 +02:00
parent 274cd45f49
commit b69cae8a5d
21 changed files with 636 additions and 381 deletions

View File

@@ -22,7 +22,7 @@
#include <boost/config/warning_disable.hpp>
#include <boost/config.hpp>
#define LIBPKMGC_VERSION 1002000
#define LIBPKMGC_VERSION 1002001
#define LIBPKMGC_VERSION_MAJOR ((LIBPKMGC_VERSION / 1000000) % 1000)
#define LIBPKMGC_VERSION_MINOR ((LIBPKMGC_VERSION / 1000) % 1000)
#define LIBPKMGC_VERSION_BUILD (LIBPKMGC_VERSION % 1000)

View File

@@ -135,8 +135,11 @@ public:
>::type reverse_generator_type;
static u32 advance32(forward_generator_type rng) {
return (rng() & 0xffff) | (rng() << 16);
}
bool buildParallelSeedTable(u32 initialSeed, u32 nbThreads, u32* outSeeds) {
static bool buildParallelSeedTable(u32 initialSeed, u32 nbThreads, u32* outSeeds) {
if (nbThreads == 0) return false;
outSeeds[0] = initialSeed;
switch (nbThreads) {

View File

@@ -57,9 +57,10 @@ public:
size_t recount(void) const;
void sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19b]); // only entries containing a valid Gen III species index are sorted
virtual void fixInvalidEntries(void);
void sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19d]); // only entries containing a valid Gen III species index are sorted
virtual void fixInvalidEntries(StrategyMemoEntry** dst = NULL);
void setInfoCompletenessForAll(bool incomplete);
u16 nbEntries;
StrategyMemoEntry* entries[500];
@@ -69,6 +70,41 @@ protected:
virtual void deleteFields(void);
virtual void loadFields(void);
public:
template<typename RNGType>
void clearMemo(RNGType& rng) {
nbEntries = 0;
for (size_t i = 0; i < 500; ++i) {
entries[i]->species = NoSpecies;
entries[i]->flags = 0;
entries[i]->generateRandomPID(rng);
}
}
template<typename RNGType>
void fillMemo(RNGType& rng, bool allShiny = false) {
allShiny = allShiny && !isXD();
StrategyMemoEntry* bySpecies[0x19d];
fixInvalidEntries(bySpecies);
for (PokemonSpeciesIndex i = NoSpecies; i <= Chimecho; i = (PokemonSpeciesIndex)(i+1)) {
size_t index = (size_t)i;
if (!getSpeciesData(i).isValid) continue;
if (bySpecies[i] == NULL) {
StrategyMemoEntry *entry = entries[nbEntries++];
bySpecies[i] = entry;
entry->species = i;
entry->firstTID = (u16)((u32)rng() >> 16);
entry->firstSID = (u16)((u32)rng() >> 16);
entries[nbEntries]->generateRandomPID(rng);
}
StrategyMemoEntry *entry = bySpecies[i];
if (allShiny) entry->firstSID = entry->firstTID ^ (entry->firstPID >> 16) ^ (entry->firstPID & 0xffff);
}
setInfoCompletenessForAll(false);
}
};
}

View File

@@ -52,10 +52,18 @@ public:
void swap(StrategyMemoEntry& other);
bool isEmpty(void) const;
bool isShiny(void) const;
template<typename RNGType>
void generateRandomPID(RNGType& rng) {
firstPID = (((u32)rng() >> 16) | (((u32)rng() >> 16) << 16)) % 0xffffffff; // <-- no & 0xffff here
}
virtual bool isInfoIncomplete(void) const = 0;
virtual void setInfoCompleteness(bool incomplete) = 0;
u16 flags;
PokemonSpeciesIndex species;
u16 firstSID, firstTID;

View File

@@ -52,11 +52,9 @@ StrategyMemoData& StrategyMemoData::operator=(StrategyMemoData const& other) {
void StrategyMemoData::loadFields(void) {
LD_FIELD(u16, nbEntries, 0);
//if (nbEntries > 0x1f4) nbEntries = 0x1f4;
}
void StrategyMemoData::save(void) {
//if (nbEntries > 0x1f4) nbEntries = 0x1f4;
SV_FIELD(u16, nbEntries, 0);
}
@@ -101,16 +99,16 @@ size_t StrategyMemoData::recount(void) const {
return i;
}
void StrategyMemoData::sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19b]) {
std::fill(dst, dst + 0x19b, (StrategyMemoEntry*)NULL);
void StrategyMemoData::sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19d]) {
std::fill(dst, dst + 0x19d, (StrategyMemoEntry*)NULL);
for (size_t i = 0; i < (size_t)nbEntries; ++i) {
size_t index = (size_t)entries[i]->species;
if ((dst[index] != NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) dst[index] = entries[i];
if ((dst[index] == NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) dst[index] = entries[i];
}
}
void StrategyMemoData::fixInvalidEntries(void) {
StrategyMemoEntry* bySpecies[0x19b] = { NULL };
void StrategyMemoData::fixInvalidEntries(StrategyMemoEntry** dst) {
StrategyMemoEntry* bySpecies[0x19d] = { NULL };
StrategyMemoEntry* entries2[500] = { NULL };
StrategyMemoEntry* emptyobj = entries[0]->create();
@@ -118,7 +116,7 @@ void StrategyMemoData::fixInvalidEntries(void) {
nbEntries = 0;
for (size_t i = 0; i < 500; ++i) {
size_t index = (size_t)entries[i]->species;
if ((bySpecies[index] != NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) {
if ((bySpecies[index] == NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) {
bySpecies[index] = entries[i];
entries2[nbEntries++] = entries[i];
}
@@ -131,8 +129,13 @@ void StrategyMemoData::fixInvalidEntries(void) {
if (entries2[i] == NULL) entries2[i] = emptyobj->clone();
}
std::copy(entries2, entries2 + nbEntries, entries);
std::copy(entries2, entries2 + 500, entries);
delete emptyobj;
if (dst != NULL) std::copy(bySpecies, bySpecies + 0x19d, dst);
}
void StrategyMemoData::setInfoCompletenessForAll(bool incomplete) {
for (size_t i = 0; i < 500; ++i) entries[i]->setInfoCompleteness(incomplete);
}
}

View File

@@ -59,9 +59,15 @@ void StrategyMemoEntry::save(void) {
SV_FIELD(u32, firstPID, 8);
}
bool StrategyMemoEntry::isShiny(void) const {
return !isXD() && (((firstPID >> 16) ^ (firstPID & 0xffff) ^ firstSID ^ firstTID) < 8);
}
bool StrategyMemoEntry::isEmpty(void) const {
return species == NoSpecies;
}
}
}