• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / libsiedler2 / 14537997660

18 Apr 2025 04:06PM UTC coverage: 81.697% (-0.3%) from 82.012%
14537997660

push

github

Flamefire
Require Boost 1.73

An undefined `PTHREAD_STACK_MIN` causes a compile failure otherwise.

5200 of 6365 relevant lines covered (81.7%)

4237.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.19
/src/LoadLST.cpp
1
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "Archiv.h"
6
#include "ArchivItem.h"
7
#include "ErrorCodes.h"
8
#include "OpenMemoryStream.h"
9
#include "prototypen.h"
10
#include "libendian/EndianIStreamAdapter.h"
11

12
/**
13
 *  lädt eine LST-File in ein Archiv.
14
 *
15
 *  @param[in]  filepath    Dateiname der LST-File
16
 *  @param[in]  palette Grundpalette der LST-File
17
 *  @param[out] items   Archiv-Struktur, welche gefüllt wird
18
 *
19
 *  @return Null bei Erfolg, ein Wert ungleich Null bei Fehler
20
 */
21
int libsiedler2::loader::LoadLST(const boost::filesystem::path& filepath, Archiv& items,
54✔
22
                                 const ArchivItem_Palette* palette)
23
{
24
    MMStream mmapStream;
108✔
25
    if(int ec = openMemoryStream(filepath, mmapStream))
54✔
26
        return ec;
×
27

28
    libendian::EndianIStreamAdapter<false, MMStream&> lst(mmapStream);
54✔
29

30
    uint16_t header;
31
    uint32_t count;
32

33
    // Header einlesen
34
    lst >> header;
54✔
35

36
    // ist es eine GER/ENG-File? (Header 0xE7FD)
37
    if(header == 0xFDE7)
54✔
38
        return LoadTXT(filepath, items, true);
1✔
39

40
    // ist es eine LST-File? (Header 0x204E)
41
    if(header != 0x4E20)
53✔
42
        return ErrorCode::WRONG_HEADER;
×
43

44
    // Anzahl einlesen
45
    lst >> count;
53✔
46

47
    if(!lst)
53✔
48
        return ErrorCode::WRONG_FORMAT;
×
49

50
    items.clear();
53✔
51

52
    // items einlesen
53
    for(uint32_t i = 0; i < count; ++i)
174✔
54
    {
55
        int16_t used;
56
        int16_t bobtype_s;
57

58
        // use-Flag einlesen
59
        if(!(lst >> used))
133✔
60
            return ErrorCode::UNEXPECTED_EOF;
12✔
61

62
        // ist das Item benutzt?
63
        if(used != 1)
133✔
64
        {
65
            items.push(nullptr);
79✔
66
            continue;
79✔
67
        }
68

69
        // bobtype des Items einlesen
70
        lst >> bobtype_s;
54✔
71
        auto bobtype = static_cast<BobType>(bobtype_s);
54✔
72

73
        // Daten von Item auswerten
74
        std::unique_ptr<ArchivItem> item;
×
75
        if(int ec = LoadType(bobtype, lst.getStream(), item, palette))
54✔
76
            return ec;
12✔
77
        items.push(std::move(item));
42✔
78
    }
79

80
    return ErrorCode::NONE;
41✔
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc