Skip to content

Commit 9d09275

Browse files
committed
Fixed getdb
Nia added some more inconsistencies to forms that needed fixing. Probably will break at some point again
1 parent 632242c commit 9d09275

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

mods/getdb.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
sendResults('Failed to get protos.', $update, true);
2222
}
2323

24-
[$form_ids, $costume] = $protos;
24+
[$form_ids, $form_names, $costume] = $protos;
2525
// Parse the game master data together with form ids into format we can use
26-
$pokemon_array = parse_master_into_pokemon_table($form_ids, $game_master_url);
26+
$pokemon_array = parse_master_into_pokemon_table($form_ids, $form_names, $game_master_url);
2727
if(!$pokemon_array) {
2828
sendResults('Failed to open game master file.', $update, true);
2929
}
@@ -129,7 +129,7 @@ function get_protos($proto_url) {
129129
if(!$proto_file = curl_get_contents($proto_url)) return false;
130130
$proto = preg_split('/\r\n|\r|\n/', $proto_file);
131131
$count = count($proto);
132-
$form_ids = $costume = array();
132+
$form_ids = $costume = $form_names = array();
133133
$data_array = false;
134134
for($i=0;$i<$count;$i++) {
135135
$line = trim($proto[$i]);
@@ -147,6 +147,9 @@ function get_protos($proto_url) {
147147
$value = explode('"', $data[1]);
148148
if(strlen($value[1]) > 0) {
149149
${$data_array}[trim($value[1])] = trim($data[0]);
150+
if($data_array == 'form_ids') {
151+
$form_names[trim($data[0])] = trim($value[1]);
152+
}
150153
}
151154
continue;
152155
}
@@ -160,10 +163,10 @@ function get_protos($proto_url) {
160163
}
161164
}
162165
unset($proto);
163-
return [$form_ids, $costume];
166+
return [$form_ids, $form_names, $costume];
164167
}
165168

166-
function parse_master_into_pokemon_table($form_ids, $game_master_url) {
169+
function parse_master_into_pokemon_table($form_ids, $form_names, $game_master_url) {
167170
// Set ID's for mega evolutions
168171
// Using negative to prevent mixup with actual form ID's
169172
// Collected from pogoprotos (hoping they won't change, so hard coding them here)
@@ -207,10 +210,15 @@ function parse_master_into_pokemon_table($form_ids, $game_master_url) {
207210
$form_data = $row['data']['formSettings']['forms'];
208211
}
209212
foreach($form_data as $form) {
210-
$form_name = strtolower(str_replace($pokemon_name.'_','',$form['form']));
213+
// This is some new niantic shit
214+
$pokemon_form_name = $form['form'];
215+
if(is_int($form['form'])) {
216+
$pokemon_form_name = $form_names[$form['form']];
217+
}
218+
$form_name = strtolower(str_replace($pokemon_name.'_','',$pokemon_form_name));
211219
if($form_name == 'purified' || $form_name == 'shadow') continue;
212220
$poke_name = ucfirst(strtolower($row['data']['formSettings']['pokemon']));
213-
$form_id = $form_ids[$form['form']] ?? 0;
221+
$form_id = $form_ids[$pokemon_form_name] ?? 0;
214222

215223
$pokemon_array[$pokemon_id][$form_name] = [
216224
'pokemon_name' => $poke_name,

0 commit comments

Comments
 (0)