~openmw/openmw/openmw-packaging2

« back to all changes in this revision

Viewing changes to apps/esmtool/esmtool.cpp

  • Committer: Scott Howard
  • Date: 2016-09-15 20:56:29 UTC
  • Revision ID: showard@debian.org-20160915205629-3tvfxe47zrb41a91
Cron update. Git hash: 37278b5

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include <map>
6
6
#include <set>
7
7
#include <fstream>
 
8
#include <cmath>
8
9
 
9
10
#include <boost/program_options.hpp>
10
11
 
354
355
            esm.getRecHeader(flags);
355
356
 
356
357
            EsmTool::RecordBase *record = EsmTool::RecordBase::create(n);
357
 
            if (record == 0) 
 
358
            if (record == 0)
358
359
            {
359
 
                if (std::find(skipped.begin(), skipped.end(), n.val) == skipped.end())
 
360
                if (std::find(skipped.begin(), skipped.end(), n.intval) == skipped.end())
360
361
                {
361
362
                    std::cout << "Skipping " << n.toString() << " records." << std::endl;
362
 
                    skipped.push_back(n.val);
 
363
                    skipped.push_back(n.intval);
363
364
                }
364
365
 
365
366
                esm.skipRecord();
391
392
                record->print();
392
393
            }
393
394
 
394
 
            if (record->getType().val == ESM::REC_CELL && loadCells && interested) 
 
395
            if (record->getType().intval == ESM::REC_CELL && loadCells && interested)
395
396
            {
396
397
                loadCell(record->cast<ESM::Cell>()->get(), esm, info);
397
398
            }
398
399
 
399
 
            if (save) 
 
400
            if (save)
400
401
            {
401
402
                info.data.mRecords.push_back(record);
402
 
            } 
403
 
            else 
 
403
            }
 
404
            else
404
405
            {
405
406
                delete record;
406
407
            }
407
 
            ++info.data.mRecordStats[n.val];
 
408
            ++info.data.mRecordStats[n.intval];
408
409
        }
409
410
 
410
411
    } catch(std::exception &e) {
442
443
    size_t recordCount = info.data.mRecords.size();
443
444
 
444
445
    int digitCount = 1; // For a nicer output
445
 
    if (recordCount > 9) ++digitCount;
446
 
    if (recordCount > 99) ++digitCount;
447
 
    if (recordCount > 999) ++digitCount;
448
 
    if (recordCount > 9999) ++digitCount;
449
 
    if (recordCount > 99999) ++digitCount;
450
 
    if (recordCount > 999999) ++digitCount;
 
446
    if (recordCount > 0)
 
447
        digitCount = (int)std::log10(recordCount) + 1;
451
448
 
452
449
    std::cout << "Loaded " << recordCount << " records:" << std::endl << std::endl;
453
450
 
454
 
    ESM::NAME name;
455
 
 
456
451
    int i = 0;
457
452
    typedef std::map<int, int> Stats;
458
453
    Stats &stats = info.data.mRecordStats;
459
454
    for (Stats::iterator it = stats.begin(); it != stats.end(); ++it)
460
455
    {
461
 
        name.val = it->first;
 
456
        ESM::NAME name;
 
457
        name.intval = it->first;
462
458
        int amount = it->second;
463
459
        std::cout << std::setw(digitCount) << amount << " " << name.toString() << "  ";
464
460
 
491
487
    for (Records::iterator it = records.begin(); it != records.end() && i > 0; ++it)
492
488
    {
493
489
        EsmTool::RecordBase *record = *it;
494
 
        name.val = record->getType().val;
 
490
        const ESM::NAME& typeName = record->getType();
495
491
 
496
 
        esm.startRecord(name.toString(), record->getFlags());
 
492
        esm.startRecord(typeName.toString(), record->getFlags());
497
493
 
498
494
        record->save(esm);
499
 
        if (name.val == ESM::REC_CELL) {
 
495
        if (typeName.intval == ESM::REC_CELL) {
500
496
            ESM::Cell *ptr = &record->cast<ESM::Cell>()->get();
501
497
            if (!info.data.mCellRefs[ptr].empty()) {
502
498
                typedef std::deque<std::pair<ESM::CellRef, bool> > RefList;
508
504
            }
509
505
        }
510
506
 
511
 
        esm.endRecord(name.toString());
 
507
        esm.endRecord(typeName.toString());
512
508
 
513
509
        saved++;
514
510
        int perc = (int)((saved / (float)recordCount)*100);