Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception - number_format(): Argument #1 ($num) must be of type float, string given #46

Closed
peycho opened this issue Apr 13, 2024 · 4 comments

Comments

@peycho
Copy link

peycho commented Apr 13, 2024

I'm installing the whole setup in a fresh host.

When the installer reaches the SqlGen::generate() - filling aowow_item_stats with data - I've got the following error:

12:53:34          SqlGen::generate() - filling aowow_item_stats with data
12:53:34           - applying stats for enchantments
12:53:39             2656 enchantments parsed
12:53:39           - applying stats for items
12:53:52           * batch #5 (1000)Exception - number_format(): Argument #1 ($num) must be of type float, string given
   /web/setup/tools/sqlgen/item_stats.func.php(112)
#0 /web/setup/tools/sqlgen/item_stats.func.php(112): number_format()
#1 /web/setup/tools/sqlgen/item_stats.func.php(266): ItemStatSetup->writeStatsTable()
#2 /web/setup/tools/sqlGen.class.php(239): SetupScript@anonymous->generate()
#3 /web/setup/tools/clisetup/setup.func.php(294): SqlGen::generate()
#4 /web/setup/setup.php(40): setup()
#5 /web/aowow(10): require('...')
#6 {main}

System:

  • OS: Ubuntu 22.04
  • PHP version: PHP 8.1.2-1ubuntu2.15
  • revision used: ec1a2af
  • Browser (in case of JavaScript / display errors): n/a
  • TrinityCore db TDB_full_world_335.21101_2021_10_15)
@peycho
Copy link
Author

peycho commented Apr 13, 2024

Ok this works:

        // collect data and write to DB
        foreach ($this->iterate() as $__)
        {
            $updateFields = ['type' => Type::ITEM, 'typeId' => $this->id];

            foreach (@$this->json[$this->id] as $k => $v)
            {
                if (!in_array($k, $this->statCols) || !$v || $k == 'id')
                    continue;

                $updateFields[$k] = number_format((float)$v, 2, '.', '');
            }

            if (isset($this->itemMods[$this->id]))
            {
                foreach ($this->itemMods[$this->id] as $k => $v)
                {
                    if (!$v)
                        continue;
                    if ($str = Game::$itemMods[$k])
                        $updateFields[$str] = number_format((float)$v, 2, '.', '');
                }
            }

            DB::Aowow()->query('REPLACE INTO ?_item_stats (?#) VALUES (?a)', array_keys($updateFields), array_values($updateFields));
        }

@Sarjuuk
Copy link
Collaborator

Sarjuuk commented Apr 17, 2024

keep your workaround for now.

I'm currently rewriting how player stats are handled because of Sarjuuk#389 and that will obvioulsy affect the item-stats setup step as a whole

@Sarjuuk
Copy link
Collaborator

Sarjuuk commented Jun 16, 2024

error source removed in Sarjuuk@d16b08b

needs to be merged

@Aokromes
Copy link
Member

error source removed in Sarjuuk@d16b08b

needs to be merged

you know, you have push (and sync) permisions here xd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants