Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/3do_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <rwe/vertex_height.h>
#include <vector>

void print3doObject(unsigned int indent, const std::vector<rwe::_3do::Object>& os)
void print3doObject(int indent, const std::vector<rwe::_3do::Object>& os)
{
for (const auto& o : os)
{
Expand Down
2 changes: 1 addition & 1 deletion src/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace rwe
{
void loadPalette(std::istream& in, png::rgb_pixel* buffer)
{
for (unsigned int i = 0; i < 256; ++i)
for (int i = 0; i < 256; ++i)
{
in.read(reinterpret_cast<char*>(&(buffer[i].red)), 1);
in.read(reinterpret_cast<char*>(&(buffer[i].green)), 1);
Expand Down
18 changes: 9 additions & 9 deletions src/fnt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ void renderFontFile(std::istream& in, std::ostream& out)
std::vector<char> v(512);

png::image<png::rgb_pixel> image(256, 512);
for (unsigned int i = 0; i < 256; ++i)
for (int i = 0; i < 256; ++i)
{
auto charX = (i % 16) * 16;
auto charY = (i / 16) * 32;
int charX = (i % 16) * 16;
int charY = (i / 16) * 32;

auto byteLength = fnt.extract(i, v.data());
auto width = byteLength / 2;
auto bitLength = byteLength * 8;
int byteLength = fnt.extract(i, v.data());
int width = byteLength / 2;
int bitLength = byteLength * 8;

for (unsigned int j = 0; j < bitLength; ++j)
for (int j = 0; j < bitLength; ++j)
{
auto dx = j % width;
auto dy = j / width;
int dx = j % width;
int dy = j / width;
if (dy >= fnt.glyphHeight())
{
break;
Expand Down
2 changes: 1 addition & 1 deletion src/gaf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void loadPalette(const std::string& filename, png::rgb_pixel* buffer)
{
std::ifstream in(filename, std::ios::binary);

for (unsigned int i = 0; i < 256; ++i)
for (int i = 0; i < 256; ++i)
{
in.read(reinterpret_cast<char*>(&(buffer[i].red)), 1);
in.read(reinterpret_cast<char*>(&(buffer[i].green)), 1);
Expand Down
10 changes: 5 additions & 5 deletions src/hpi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ std::string schemeName(rwe::HpiArchive::File::CompressionScheme scheme)
}
}

void printDir(unsigned int indent, const std::string& name, const rwe::HpiArchive::Directory& d);
void printFile(unsigned int indent, const std::string& name, const rwe::HpiArchive::File& f);
void printDir(int indent, const std::string& name, const rwe::HpiArchive::Directory& d);
void printFile(int indent, const std::string& name, const rwe::HpiArchive::File& f);

void printEntry(unsigned int indent, const rwe::HpiArchive::DirectoryEntry& e)
void printEntry(int indent, const rwe::HpiArchive::DirectoryEntry& e)
{
match(
e.data,
Expand All @@ -38,7 +38,7 @@ void printEntry(unsigned int indent, const rwe::HpiArchive::DirectoryEntry& e)
});
}

void printDir(unsigned int indent, const std::string& name, const rwe::HpiArchive::Directory& d)
void printDir(int indent, const std::string& name, const rwe::HpiArchive::Directory& d)
{
std::string dent(indent, ' ');
std::cout << dent << name << " directory:" << std::endl;
Expand All @@ -48,7 +48,7 @@ void printDir(unsigned int indent, const std::string& name, const rwe::HpiArchiv
}
}

void printFile(unsigned int indent, const std::string& name, const rwe::HpiArchive::File& f)
void printFile(int indent, const std::string& name, const rwe::HpiArchive::File& f)
{
std::string compression = schemeName(f.compressionScheme);

Expand Down
12 changes: 6 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace rwe
return Ok(std::move(glContext));
};

int run(spdlog::logger& logger, const std::vector<fs::path>& searchPath, const PathMapping& pathMapping, const std::optional<GameParameters>& gameParameters, unsigned int desiredWindowWidth, unsigned int desiredWindowHeight, bool fullscreen, const std::string& imGuiIniPath, GlobalConfig& globalConfig)
int run(spdlog::logger& logger, const std::vector<fs::path>& searchPath, const PathMapping& pathMapping, const std::optional<GameParameters>& gameParameters, int desiredWindowWidth, int desiredWindowHeight, bool fullscreen, const std::string& imGuiIniPath, GlobalConfig& globalConfig)
{
logger.info(ProjectNameVersion);
logger.info("Current directory: {0}", fs::current_path().string());
Expand Down Expand Up @@ -526,8 +526,8 @@ int main(int argc, char* argv[])
("help", "produce help message")
("log", po::value<std::string>(), "Sets the log output file path")
("state-log", po::value<std::string>(), "Sets the output file for sim-state logs. This is a desync debugging feature.")
("width", po::value<unsigned int>()->default_value(800), "Sets the window width in pixels")
("height", po::value<unsigned int>()->default_value(600), "Sets the window height in pixels")
("width", po::value<int>()->default_value(800), "Sets the window width in pixels")
("height", po::value<int>()->default_value(600), "Sets the window height in pixels")
("fullscreen", po::bool_switch(), "Starts the application in fullscreen mode")
("interface-mode", po::value<std::string>()->default_value("left-click"), "left-click or right-click")
("data-path", po::value<std::vector<std::string>>(), "Sets the location(s) to search for game data")
Expand Down Expand Up @@ -591,7 +591,7 @@ int main(int argc, char* argv[])
gameParameters->stateLogFile = vm["state-log"].as<std::string>();
}
gameParameters->localNetworkPort = vm["port"].as<std::string>();
unsigned int playerIndex = 0;
int playerIndex = 0;
if (players.size() > 10)
{
throw std::runtime_error("too many players");
Expand All @@ -615,8 +615,8 @@ int main(int argc, char* argv[])
gameDataPaths.emplace_back(*localDataPath) /= "Data";
}

auto screenWidth = vm["width"].as<unsigned int>();
auto screenHeight = vm["height"].as<unsigned int>();
auto screenWidth = vm["width"].as<int>();
auto screenHeight = vm["height"].as<int>();
auto fullscreen = vm["fullscreen"].as<bool>();

auto pathMapping = constructDefaultPathMapping();
Expand Down
4 changes: 2 additions & 2 deletions src/pcx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ int convert(const std::string& inFile, const std::string& outFile)
auto decodedData = decoder.decodeImage();
auto palette = decoder.decodePalette();

auto width = decoder.getWidth();
auto height = decoder.getHeight();
int width = decoder.getWidth();
int height = decoder.getHeight();

png::image<png::rgb_pixel> image(width, height);
for (png::uint_32 y = 0; y < height; ++y)
Expand Down
8 changes: 4 additions & 4 deletions src/rwe/AudioService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ namespace rwe
return sound;
}

void AudioService::reserveChannels(unsigned int count)
void AudioService::reserveChannels(int count)
{
auto num = sdlMixerContext->reserveChannels(count);
int num = sdlMixerContext->reserveChannels(count);
assert(num >= 0);
if (static_cast<unsigned int>(num) < count)
if (num < count)
{
throw std::runtime_error("Failed to reserve audio channels");
}
Expand All @@ -64,7 +64,7 @@ namespace rwe
sdlMixerContext->haltChannel(channel);
}

void AudioService::playSoundIfFree(const AudioService::SoundHandle& sound, unsigned int channel)
void AudioService::playSoundIfFree(const AudioService::SoundHandle& sound, int channel)
{
if (sdlMixerContext->playing(channel))
{
Expand Down
4 changes: 2 additions & 2 deletions src/rwe/AudioService.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ namespace rwe

std::optional<SoundHandle> loadSound(const std::string& soundName);

void reserveChannels(unsigned int count);
void reserveChannels(int count);

void playSoundIfFree(const SoundHandle& sound, unsigned int channel);
void playSoundIfFree(const SoundHandle& sound, int channel);

void setVolume(int channel, int volume);

Expand Down
2 changes: 1 addition & 1 deletion src/rwe/BoxTreeSplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace rwe
{
Size::Size(std::size_t width, std::size_t height) : width(width), height(height)
Size::Size(int width, int height) : width(width), height(height)
{
}
}
46 changes: 23 additions & 23 deletions src/rwe/BoxTreeSplit.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ namespace rwe
template <typename T>
struct BoxPackInfoEntry
{
unsigned int x;
unsigned int y;
int x;
int y;
T value;
};

template <typename T>
struct BoxPackInfo
{
unsigned int width;
unsigned int height;
int width;
int height;

std::vector<BoxPackInfoEntry<T>> entries;
};
Expand All @@ -40,8 +40,8 @@ namespace rwe
template <typename T>
struct BoxTreeNode
{
unsigned int width;
unsigned int height;
int width;
int height;

using Union = std::variant<BoxTreeSplit<T>, BoxTreeLeaf<T>>;

Expand All @@ -52,13 +52,13 @@ namespace rwe
std::unique_ptr<BoxTreeNode>&& left,
std::unique_ptr<BoxTreeNode>&& right);

BoxTreeNode(unsigned int width, unsigned int height);
BoxTreeNode(int width, int height);

BoxTreeNode(unsigned int width, unsigned int height, const T& value);
BoxTreeNode(int width, int height, const T& value);

BoxTreeNode(unsigned int width, unsigned int height, T&& value);
BoxTreeNode(int width, int height, T&& value);

std::optional<BoxTreeNode<T>*> findNode(unsigned int itemWidth, unsigned int itemHeight);
std::optional<BoxTreeNode<T>*> findNode(int itemWidth, int itemHeight);

std::vector<BoxPackInfoEntry<T>> walk();
};
Expand Down Expand Up @@ -97,19 +97,19 @@ namespace rwe
{
std::unique_ptr<BoxTreeNode<T>> root;

BoxTree(unsigned int width, unsigned int height, const T& value)
BoxTree(int width, int height, const T& value)
: root(std::make_unique<BoxTreeNode<T>>(width, height, value))
{
}

BoxTree(unsigned int width, unsigned int height, T&& value)
BoxTree(int width, int height, T&& value)
: root(std::make_unique<BoxTreeNode<T>>(width, height, std::move(value)))
{
}

BoxTreeNode<T>* findOrCreateNode(unsigned int itemWidth, unsigned int itemHeight);
BoxTreeNode<T>* findOrCreateNode(int itemWidth, int itemHeight);

void insert(unsigned int itemWidth, unsigned int itemHeight, const T& item);
void insert(int itemWidth, int itemHeight, const T& item);
};

enum class GrowDirection
Expand All @@ -119,7 +119,7 @@ namespace rwe
};

template <typename T>
BoxTreeNode<T>* BoxTree<T>::findOrCreateNode(unsigned int itemWidth, unsigned int itemHeight)
BoxTreeNode<T>* BoxTree<T>::findOrCreateNode(int itemWidth, int itemHeight)
{
// find a leaf node big enough to fit the box
auto node = root->findNode(itemWidth, itemHeight);
Expand Down Expand Up @@ -165,7 +165,7 @@ namespace rwe
}

template <typename T>
void BoxTree<T>::insert(unsigned int itemWidth, unsigned int itemHeight, const T& item)
void BoxTree<T>::insert(int itemWidth, int itemHeight, const T& item)
{
auto node = findOrCreateNode(itemWidth, itemHeight);

Expand Down Expand Up @@ -211,25 +211,25 @@ namespace rwe
}

template <typename T>
BoxTreeNode<T>::BoxTreeNode(unsigned int width, unsigned int height)
BoxTreeNode<T>::BoxTreeNode(int width, int height)
: width(width), height(height), value(BoxTreeLeaf<T>())
{
}

template <typename T>
BoxTreeNode<T>::BoxTreeNode(unsigned int width, unsigned int height, const T& value)
BoxTreeNode<T>::BoxTreeNode(int width, int height, const T& value)
: width(width), height(height), value(BoxTreeLeaf<T>(value))
{
}

template <typename T>
BoxTreeNode<T>::BoxTreeNode(unsigned int width, unsigned int height, T&& value)
BoxTreeNode<T>::BoxTreeNode(int width, int height, T&& value)
: width(width), height(height), value(BoxTreeLeaf<T>(std::move(value)))
{
}

template <typename T>
std::optional<BoxTreeNode<T>*> BoxTreeNode<T>::findNode(unsigned int itemWidth, unsigned int itemHeight)
std::optional<BoxTreeNode<T>*> BoxTreeNode<T>::findNode(int itemWidth, int itemHeight)
{
if (itemWidth > width || itemHeight > height)
{
Expand Down Expand Up @@ -297,11 +297,11 @@ namespace rwe

struct Size
{
std::size_t width;
std::size_t height;
int width;
int height;

Size() = default;
Size(std::size_t width, std::size_t height);
Size(int width, int height);
};

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/rwe/ColorPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace rwe

std::vector<Color> colors(256);

for (unsigned int i = 0; i < 256; ++i)
for (int i = 0; i < 256; ++i)
{
colors[i].r = static_cast<unsigned char>(vector[(4 * i)]);
colors[i].g = static_cast<unsigned char>(vector[(4 * i) + 1]);
Expand Down
4 changes: 2 additions & 2 deletions src/rwe/CursorService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace rwe

auto timeInMillis = timeService->getTicks();
const auto& frames = currentCursor->sprites;
unsigned int frameRateInSeconds = 6;
unsigned int millisPerFrame = 1000 / frameRateInSeconds;
int frameRateInSeconds = 6;
int millisPerFrame = 1000 / frameRateInSeconds;

auto frameIndex = (timeInMillis / millisPerFrame) % frames.size();

Expand Down
2 changes: 1 addition & 1 deletion src/rwe/GameHash_util.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace rwe
{
struct IdTag;
using Id = OpaqueId<unsigned int, IdTag>;
using Id = OpaqueId<int, IdTag>;

enum class TestEnum
{
Expand Down
8 changes: 4 additions & 4 deletions src/rwe/GameNetworkService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace rwe

SceneTime GameNetworkService::estimateAvergeSceneTime(SceneTime localSceneTime)
{
std::promise<unsigned int> result;
std::promise<int> result;
ioContext.post([this, localSceneTime, &result]() {
auto time = getTimestamp();
auto otherTimes = choose(endpoints, [](const auto& e) { return e.lastKnownSceneTime; });
Expand Down Expand Up @@ -226,7 +226,7 @@ namespace rwe
}
}

void GameNetworkService::receive(const boost::system::error_code& error, std::size_t receivedBytes)
void GameNetworkService::receive(const boost::system::error_code& error, int receivedBytes)
{
if (error)
{
Expand Down Expand Up @@ -316,7 +316,7 @@ namespace rwe
spdlog::get("rwe")->debug("Average RTT: {0}ms", endpoint.averageRoundTripTime);
}

auto extraFrames = static_cast<unsigned int>((endpoint.averageRoundTripTime / 2.0f) * SimTicksPerSecond / 1000.0f);
auto extraFrames = static_cast<int>((endpoint.averageRoundTripTime / 2.0f) * SimTicksPerSecond / 1000.0f);
endpoint.lastKnownSceneTime = std::make_pair(SceneTime(message.current_scene_time() + extraFrames), receiveTime);
spdlog::get("rwe")->debug("Estimated peer scene time: {0}", endpoint.lastKnownSceneTime->first.value);

Expand All @@ -332,7 +332,7 @@ namespace rwe
auto firstRelevantCommandIndex = (endpoint.nextCommandToReceive - firstCommandNumber).value;

// if the packet is relevant (contains new information), process it
if (firstRelevantCommandIndex < static_cast<unsigned int>(message.command_set_size()))
if (firstRelevantCommandIndex < message.command_set_size())
{
endpoint.lastReceiveTime = receiveTime;

Expand Down
Loading