Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions include/gamepp/gamepp.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,43 @@ class GameInstance {
* @param command The command to run.
* @return This GameInstance.
*/
const GameInstance& command(std::string_view command) const;
const GameInstance& command(std::string_view command) const; // NOLINT(*-use-nodiscard)

/**
* Begin "pressing" an input such as forward or left.
* @param command The input to run (without the plus sign prefix).
* @param input The input to run (without the plus sign prefix).
* @return This GameInstance.
*/
const GameInstance& inputBegin(std::string_view input) const;
const GameInstance& inputBegin(std::string_view input) const; // NOLINT(*-use-nodiscard)

/**
* End "pressing" an input such as forward or left.
* @param command The input to run (without the minus sign prefix).
* @param input The input to run (without the minus sign prefix).
* @return This GameInstance.
*/
const GameInstance& inputEnd(std::string_view input) const;
const GameInstance& inputEnd(std::string_view input) const; // NOLINT(*-use-nodiscard)

/**
* Begin and end "pressing" an input in one tick, like tapping the use key.
* @param command The input to run (without any prefix).
* @param input The input to run (without any prefix).
* @return This GameInstance.
*/
const GameInstance& inputOnce(std::string_view input) const;
const GameInstance& inputOnce(std::string_view input) const; // NOLINT(*-use-nodiscard)

/**
* Begin and end "pressing" an input in the given timespan, like holding the use key.
* @param input The input to run (without any prefix).
* @param sec The time to hold the input for.
* @return This GameInstance.
*/
const GameInstance& inputHold(std::string_view input, double sec) const;
const GameInstance& inputHold(std::string_view input, double sec) const; // NOLINT(*-use-nodiscard)

/**
* Sleep on the current thread for the given number of seconds.
* @param sec The number of seconds.
* @return This GameInstance.
*/
const GameInstance& wait(double sec) const;
const GameInstance& wait(double sec) const; // NOLINT(*-use-nodiscard)

protected:
GameInstance() = default;
Expand Down
4 changes: 2 additions & 2 deletions include/kvpp/KV1.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ class KV1ElementWritable : public KV1ElementBase<S, KV1ElementWritable<S>> {
stream_.write('\t');
}
};
constexpr auto writeQuotedString = [](BufferStream& stream_, std::string_view str, const parser::text::EscapeSequenceMap& escapeSequences, char quoteStart = '\"', char quoteEnd = '\"') {
constexpr auto writeQuotedString = [](BufferStream& stream_, std::string_view str, const parser::text::EscapeSequenceMap& escapeSequences_, char quoteStart = '\"', char quoteEnd = '\"') {
stream_.write(quoteStart);
if (!str.empty()) {
stream_.write(parser::text::convertSpecialCharsToEscapes(str, escapeSequences), false);
stream_.write(parser::text::convertSpecialCharsToEscapes(str, escapeSequences_), false);
}
stream_.write(quoteEnd);
};
Expand Down
8 changes: 4 additions & 4 deletions include/toolpp/FGD.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class FGDWriter {

AutoVisGroupWriter& visGroup(const std::string& name, const std::vector<std::string>& entities);

FGDWriter& endAutoVisGroup();
FGDWriter& endAutoVisGroup() const; // NOLINT(*-use-nodiscard)

private:
FGDWriter& parent;
Expand All @@ -139,7 +139,7 @@ class FGDWriter {

KeyValueChoicesWriter& choice(const std::string& value, const std::string& displayName);

EntityWriter& endKeyValueChoices();
EntityWriter& endKeyValueChoices() const; // NOLINT(*-use-nodiscard)

private:
EntityWriter& parent;
Expand All @@ -151,7 +151,7 @@ class FGDWriter {

KeyValueFlagsWriter& flag(uint64_t value, const std::string& displayName, bool enabledByDefault, const std::string& description = "");

EntityWriter& endKeyValueFlags();
EntityWriter& endKeyValueFlags() const; // NOLINT(*-use-nodiscard)

private:
EntityWriter& parent;
Expand All @@ -169,7 +169,7 @@ class FGDWriter {

EntityWriter& output(const std::string& name, const std::string& valueType, const std::string& description = "");

FGDWriter& endEntity();
FGDWriter& endEntity() const; // NOLINT(*-use-nodiscard)

private:
FGDWriter& parent;
Expand Down
3 changes: 0 additions & 3 deletions include/vpkpp/PackFile.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#pragma once

#include <concepts>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <vector>

#include <sourcepp/math/Integer.h>
#include <sourcepp/Macros.h>
#include <tsl/htrie_map.h>

Expand Down
1 change: 0 additions & 1 deletion include/vpkpp/format/VPK.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <array>
#include <tuple>

#include "../PackFile.h"

Expand Down
3 changes: 0 additions & 3 deletions include/vpkpp/format/VPK_VTMB.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once

#include <array>
#include <tuple>

#include "../PackFile.h"

namespace vpkpp {
Expand Down
2 changes: 1 addition & 1 deletion include/vpkpp/format/ZIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ZIP : public PackFile {

void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;

bool bakeTempZip(const std::string& writeZipPath, BakeOptions options, const EntryCallback& callback);
bool bakeTempZip(const std::string& writeZipPath, BakeOptions options, const EntryCallback& callback) const; // NOLINT(*-use-nodiscard)

bool openZIP(std::string_view path);

Expand Down
4 changes: 2 additions & 2 deletions include/vtfpp/ImageConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct RGB888 {
};
VTFPP_CHECK_SIZE(RGB888);

struct RGB888_BLUESCREEN : public RGB888 {
struct RGB888_BLUESCREEN : RGB888 {
static constexpr auto FORMAT = ImageFormat::RGB888_BLUESCREEN;
};
VTFPP_CHECK_SIZE(RGB888_BLUESCREEN);
Expand All @@ -54,7 +54,7 @@ struct BGR888 {
};
VTFPP_CHECK_SIZE(BGR888);

struct BGR888_BLUESCREEN : public BGR888 {
struct BGR888_BLUESCREEN : BGR888 {
static constexpr auto FORMAT = ImageFormat::BGR888_BLUESCREEN;
};
VTFPP_CHECK_SIZE(BGR888_BLUESCREEN);
Expand Down
7 changes: 2 additions & 5 deletions include/vtfpp/ImageFormats.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <utility>

#include <sourcepp/math/Integer.h>

namespace vtfpp {
Expand Down Expand Up @@ -584,8 +582,7 @@ namespace ImageFormatDetails {
default:
break;
}
uint32_t out = width * height * sliceCount * bpp(format) / 8;
return out;
return width * height * sliceCount * (bpp(format) / 8);
}

[[nodiscard]] constexpr uint32_t getDataLength(ImageFormat format, uint8_t mipCount, uint16_t frameCount, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t sliceCount = 1) {
Expand All @@ -603,7 +600,7 @@ namespace ImageFormatDetails {
for (int j = 0; j < frameCount; j++) {
for (int k = 0; k < faceCount; k++) {
for (int l = 0; l < sliceCount; l++) {
auto imageSize = ImageFormatDetails::getDataLength(format, ImageDimensions::getMipDim(i, width), ImageDimensions::getMipDim(i, height));
const auto imageSize = ImageFormatDetails::getDataLength(format, ImageDimensions::getMipDim(i, width), ImageDimensions::getMipDim(i, height));
if (i == mip && j == frame && k == face && l == slice) {
length = imageSize;
return true;
Expand Down
5 changes: 2 additions & 3 deletions include/vtfpp/VTF.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <cstddef>
#include <span>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include <variant>
Expand Down Expand Up @@ -166,10 +165,10 @@ class VTF {
};

/// This value is only valid when passed to VTF::create through CreationOptions
static constexpr ImageFormat FORMAT_UNCHANGED = static_cast<ImageFormat>(-2);
static constexpr auto FORMAT_UNCHANGED = static_cast<ImageFormat>(-2);

/// This value is only valid when passed to VTF::create through CreationOptions or VTF::setFormat
static constexpr ImageFormat FORMAT_DEFAULT = static_cast<ImageFormat>(-1);
static constexpr auto FORMAT_DEFAULT = static_cast<ImageFormat>(-1);

static constexpr int32_t MAX_RESOURCES = 32;

Expand Down
36 changes: 18 additions & 18 deletions src/bsppp/bsppp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool BSP::hasLump(BSPLump lumpIndex) const {
if (this->path.empty()) {
return false;
}
auto lump = static_cast<std::underlying_type_t<BSPLump>>(lumpIndex);
const auto lump = static_cast<std::underlying_type_t<BSPLump>>(lumpIndex);
return this->header.lumps[lump].length != 0 && this->header.lumps[lump].offset != 0;
}

Expand All @@ -137,14 +137,14 @@ void BSP::setLumpVersion(BSPLump lumpIndex, int32_t version) {
this->writeHeader();
}

std::optional<std::vector<std::byte>> BSP::readLump(BSPLump lump) const {
if (this->path.empty() || !this->hasLump(lump)) {
std::optional<std::vector<std::byte>> BSP::readLump(BSPLump lumpIndex) const {
if (this->path.empty() || !this->hasLump(lumpIndex)) {
return std::nullopt;
}
FileStream reader{this->path};
return reader
.seek_in(this->header.lumps[static_cast<std::underlying_type_t<BSPLump>>(lump)].offset)
.read_bytes(this->header.lumps[static_cast<std::underlying_type_t<BSPLump>>(lump)].length);
.seek_in(this->header.lumps[static_cast<std::underlying_type_t<BSPLump>>(lumpIndex)].offset)
.read_bytes(this->header.lumps[static_cast<std::underlying_type_t<BSPLump>>(lumpIndex)].length);
}

void BSP::writeLump(BSPLump lumpIndex, std::span<const std::byte> data, bool condenseFile) {
Expand All @@ -157,10 +157,10 @@ void BSP::writeLump(BSPLump lumpIndex, std::span<const std::byte> data, bool con
if (!this->hasLump(lumpIndex) || !condenseFile) {
// Put the lump at the end of the file
int32_t lastLumpOffset = 0, lastLumpLength = 0;
for (const Lump& lump : this->header.lumps) {
for (const auto& [lumpOffset, lumpLength, lumpVersion, lumpFourCC] : this->header.lumps) {
if (lastLumpOffset < this->header.lumps[lumpToMove].offset) {
lastLumpOffset = lump.offset;
lastLumpLength = lump.length;
lastLumpOffset = lumpOffset;
lastLumpLength = lumpLength;
}
}
if (lastLumpOffset == 0) {
Expand Down Expand Up @@ -221,10 +221,10 @@ void BSP::writeLump(BSPLump lumpIndex, std::span<const std::byte> data, bool con

// Resize file if it shrank
int32_t lastLumpOffset = 0, lastLumpLength = 0;
for (const Lump& lump : this->header.lumps) {
for (const auto& [lumpOffset, lumpLength, lumpVersion, lumpFourCC] : this->header.lumps) {
if (lastLumpOffset < this->header.lumps[lumpToMove].offset) {
lastLumpOffset = lump.offset;
lastLumpLength = lump.length;
lastLumpOffset = lumpOffset;
lastLumpLength = lumpLength;
}
}
if (std::filesystem::file_size(this->path) > lastLumpOffset + lastLumpLength) {
Expand All @@ -242,10 +242,10 @@ bool BSP::applyLumpPatchFile(const std::string& lumpFilePath) {
return false;
}

auto offset = reader.read<int32_t>();
auto index = reader.read<int32_t>();
auto version = reader.read<int32_t>();
auto length = reader.read<int32_t>();
const auto offset = reader.read<int32_t>();
const auto index = reader.read<int32_t>();
const auto version = reader.read<int32_t>();
const auto length = reader.read<int32_t>();
if (index < 0 || index > BSP_LUMP_COUNT || offset <= 0 || length <= 0) {
return false;
}
Expand All @@ -261,7 +261,7 @@ void BSP::createLumpPatchFile(BSPLump lumpIndex) const {
return;
}

auto& lump = this->header.lumps.at(static_cast<std::underlying_type_t<BSPLump>>(lumpIndex));
const auto& [lumpOffset, lumpLength, lumpVersion, lumpFourCC] = this->header.lumps.at(static_cast<std::underlying_type_t<BSPLump>>(lumpIndex));

const auto fsPath = std::filesystem::path{this->path};
const auto fsStem = (fsPath.parent_path() / fsPath.stem()).string() + "_l_";
Expand All @@ -277,8 +277,8 @@ void BSP::createLumpPatchFile(BSPLump lumpIndex) const {
.seek_out(0)
.write<int32_t>(sizeof(int32_t) * 5)
.write(lumpIndex)
.write(lump.version)
.write(lump.length)
.write(lumpVersion)
.write(lumpLength)
.write(this->header.mapRevision)
.write(*lumpData);
}
Expand Down
Loading