Skip to content

Commit 04fd48d

Browse files
committed
Cull Tables Without Multiple of Species
1 parent 51607b9 commit 04fd48d

1 file changed

Lines changed: 32 additions & 11 deletions

File tree

  • src_imgui/examples/example_win32_directx9

src_imgui/examples/example_win32_directx9/main.cpp

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ enum FilterReasons
9090
{
9191
Reason_None,
9292
Reason_BadType,
93-
Reason_OverLevelCap
93+
Reason_OverLevelCap,
94+
Reason_LackingDuplicateMons
9495
};
9596

9697
struct Settings
@@ -1308,7 +1309,6 @@ static bool ReadTables(Settings* settings, SettingsWindowData* settingswindowdat
13081309
int i = 0;
13091310
for (EncounterTable* table : maintables)
13101311
{
1311-
cout << "size: " << maintables.size() << "\n";
13121312
//progress bar
13131313
i++;
13141314
settingswindowdata->progress = (1 - (static_cast<float>(maintables.size()) - i) / maintables.size()) * 0.5 + 0.5;
@@ -1326,7 +1326,6 @@ static bool ReadTables(Settings* settings, SettingsWindowData* settingswindowdat
13261326
table->totalchance = 0;//sanity check: this number should always = 100 or expectedtotalpercent at the end of the table.
13271327
for (Encounter& encounter : table->encounters)
13281328
{
1329-
if (settings->printtext) cout << table->placename << " (first in encounter loop)\n";
13301329
string expfile = game->expfile;
13311330
int generation = game->generation;
13321331
if (settings->wantedgame_index == ALLGAMES_INDEX)
@@ -1335,19 +1334,16 @@ static bool ReadTables(Settings* settings, SettingsWindowData* settingswindowdat
13351334
expfile = g_games[table->version_index]->expfile;
13361335
generation = g_games[table->version_index]->generation;
13371336
}
1338-
if (settings->printtext) cout << table->placename << " (about to do FindBEY)\n";
13391337
//get experience yield from stripped down bulba tables
13401338
if (!FindBEY(basepath, expfile, encounter.pokemonname, &encounter.baseExp))
13411339
{
13421340
cout << "ERROR: Could not find pokemon named '" << encounter.pokemonname << "' in " << expfile << "\n";
13431341
continue;
13441342
}
1345-
if (settings->printtext) cout << table->placename << " (EXP math)\n";
13461343
encounter.minlevel = max(encounter.minlevel, settings->repellevel);
13471344
double avglevel = static_cast<double>(encounter.maxlevel + encounter.minlevel) / 2;
13481345
int factor = (generation == 5 || generation >= 7) ? 5 : 7;
13491346
encounter.avgexp = (encounter.baseExp * avglevel) / factor;
1350-
if (settings->printtext) cout << table->placename << " (Level scaling)\n";
13511347
//level scaling
13521348
if (settings->scalinglevel != 0)
13531349
{
@@ -1358,13 +1354,11 @@ static bool ReadTables(Settings* settings, SettingsWindowData* settingswindowdat
13581354
if (generation >= 7)
13591355
encounter.avgexp *= pow((a) / (b), 2.5);
13601356
}
1361-
if (settings->printtext) cout << table->placename << " (before exp weighted)\n";
13621357
encounter.avgexpweighted = (encounter.avgexp * encounter.chance) / table->expectedtotalpercent;
1363-
if (settings->printtext) cout << table->placename << " (after exp weighted)\n";
13641358
if (settings->printtext) cout << encounter.pokemonname << " has " << encounter.chance << "% chance between level " << encounter.minlevel << " and " << encounter.maxlevel << ". avgexp " << encounter.avgexp << ", weighted " << encounter.avgexpweighted << "\n";
13651359
#ifdef _DEBUG
1366-
if (settings->printtext) cout << "totalavgexp " << table->totalavgexp << " += " << encounter.avgexpweighted << "\n";
1367-
if (settings->printtext) cout << "totalchance " << table->totalchance << " += " << encounter.chance << "\n\n";
1360+
//if (settings->printtext) cout << "totalavgexp " << table->totalavgexp << " += " << encounter.avgexpweighted << "\n";
1361+
//if (settings->printtext) cout << "totalchance " << table->totalchance << " += " << encounter.chance << "\n\n";
13681362
#endif //_DEBUG
13691363
table->totalavgexp += encounter.avgexpweighted;
13701364
table->totalchance += encounter.chance;
@@ -1628,7 +1622,7 @@ static void dosettingswindow(Settings* settings, Settings* newsettings, Settings
16281622
ImGui::CheckboxFlags("Old Rod", &methodflags, MethodFilterFlags_RodOld);
16291623
ImGui::CheckboxFlags("Good Rod", &methodflags, MethodFilterFlags_RodGood);
16301624
}
1631-
1625+
16321626
if (game->generation == 7)
16331627
ImGui::CheckboxFlags("Fishing at regular rock", &methodflags, MethodFilterFlags_RodSuper);
16341628
else
@@ -1805,6 +1799,33 @@ static void dosettingswindow(Settings* settings, Settings* newsettings, Settings
18051799
static bool printtext = false;
18061800
ImGui::Checkbox("Text Output", &printtext);
18071801
newsettings->printtext = printtext;
1802+
1803+
if (ImGui::Button("Cull Tables Without Multiple of Species"))
1804+
{
1805+
for (EncounterTable* table : maintables)
1806+
std::sort(table->encounters.begin(), table->encounters.end(), compareByMonName);
1807+
1808+
for (EncounterTable* table : maintables)
1809+
{
1810+
bool found = false;
1811+
string lastmonname;
1812+
for (Encounter encounter : table->encounters)
1813+
{
1814+
if (lastmonname == encounter.pokemonname)
1815+
{
1816+
//cout << lastmonname << " == " << encounter.pokemonname << "\n";
1817+
found = true;
1818+
}
1819+
lastmonname = encounter.pokemonname;
1820+
}
1821+
if (!found)
1822+
{
1823+
cout << "Culling table " << table->placename << ", " << g_methods[table->method_index]->uiname << "\n";
1824+
table->filterReason = Reason_LackingDuplicateMons;
1825+
}
1826+
}
1827+
}
1828+
ImGui::SameLine(); WarnMarker("This is a one-way operation. Hidden tables will be inaccessible until the Go button is used again.");
18081829
}
18091830

18101831
if (settingswindowdata->running)

0 commit comments

Comments
 (0)