mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-11-08 10:29:00 +00:00
Remove u16
It's better to use types from the standard library.
This commit is contained in:
110 files changed
+848
-818
No files matched your search
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "graphics/Terrain.h"
|
||||
#include "graphics/UnitManager.h"
|
||||
#include "lib/posix/posix_types.h"
|
||||
#include "lib/types.h"
|
||||
#include "maths/MathUtil.h"
|
||||
#include "maths/Vector3D.h"
|
||||
#include "ps/Game.h"
|
||||
@@ -44,7 +43,7 @@
|
||||
|
||||
namespace AtlasMessage {
|
||||
|
||||
class TerrainArray : public DeltaArray2D<u16>
|
||||
class TerrainArray : public DeltaArray2D<std::uint16_t>
|
||||
{
|
||||
public:
|
||||
void Init()
|
||||
@@ -59,7 +58,7 @@ public:
|
||||
if (size_t(x) >= size_t(m_VertsPerSide) || size_t(y) >= size_t(m_VertsPerSide))
|
||||
return;
|
||||
|
||||
set(x, y, static_cast<u16>(Clamp(get(x,y) + amount, 0, 65535)));
|
||||
set(x, y, static_cast<std::uint16_t>(Clamp(get(x,y) + amount, 0, 65535)));
|
||||
}
|
||||
|
||||
void MoveVertexTowards(ssize_t x, ssize_t y, int target, int amount)
|
||||
@@ -75,10 +74,10 @@ public:
|
||||
else
|
||||
return;
|
||||
|
||||
set(x, y, static_cast<u16>(Clamp(h, 0, 65535)));
|
||||
set(x, y, static_cast<std::uint16_t>(Clamp(h, 0, 65535)));
|
||||
}
|
||||
|
||||
void SetVertex(ssize_t x, ssize_t y, u16 value)
|
||||
void SetVertex(ssize_t x, ssize_t y, std::uint16_t value)
|
||||
{
|
||||
if (size_t(x) >= size_t(m_VertsPerSide) || size_t(y) >= size_t(m_VertsPerSide))
|
||||
return;
|
||||
@@ -86,22 +85,22 @@ public:
|
||||
set(x,y, value);
|
||||
}
|
||||
|
||||
u16 GetVertex(ssize_t x, ssize_t y)
|
||||
std::uint16_t GetVertex(ssize_t x, ssize_t y)
|
||||
{
|
||||
return get(Clamp<ssize_t>(x, 0, m_VertsPerSide - 1), Clamp<ssize_t>(y, 0, m_VertsPerSide - 1));
|
||||
}
|
||||
|
||||
protected:
|
||||
u16 getOld(ssize_t x, ssize_t y)
|
||||
std::uint16_t getOld(ssize_t x, ssize_t y)
|
||||
{
|
||||
return m_Heightmap[y*m_VertsPerSide + x];
|
||||
}
|
||||
void setNew(ssize_t x, ssize_t y, const u16& val)
|
||||
void setNew(ssize_t x, ssize_t y, const std::uint16_t& val)
|
||||
{
|
||||
m_Heightmap[y*m_VertsPerSide + x] = val;
|
||||
}
|
||||
|
||||
u16* m_Heightmap;
|
||||
std::uint16_t* m_Heightmap;
|
||||
ssize_t m_VertsPerSide;
|
||||
};
|
||||
|
||||
@@ -332,7 +331,7 @@ BEGIN_COMMAND(FlattenElevation)
|
||||
|
||||
ssize_t xc, yc;
|
||||
g_CurrentBrush.GetCentre(xc, yc);
|
||||
u16 height = m_TerrainDelta.GetVertex(xc, yc);
|
||||
std::uint16_t height = m_TerrainDelta.GetVertex(xc, yc);
|
||||
|
||||
ssize_t x0, y0;
|
||||
g_CurrentBrush.GetBottomLeft(x0, y0);
|
||||
|
||||
@@ -219,7 +219,7 @@ MESSAGEHANDLER(LoadMap)
|
||||
|
||||
MESSAGEHANDLER(ImportHeightmap)
|
||||
{
|
||||
std::vector<u16> heightmap_source;
|
||||
std::vector<std::uint16_t> heightmap_source;
|
||||
if (LoadHeightmapImageOs(*msg->filename, heightmap_source) != INFO::OK)
|
||||
{
|
||||
LOGERROR("Failed to decode heightmap.");
|
||||
@@ -235,7 +235,7 @@ MESSAGEHANDLER(ImportHeightmap)
|
||||
terrain.ResizeAndOffset(newSize, offset, offset);
|
||||
|
||||
// copy heightmap data into map
|
||||
u16* const heightmap = g_Game->GetWorld()->GetTerrain().GetHeightMap();
|
||||
std::uint16_t* const heightmap = g_Game->GetWorld()->GetTerrain().GetHeightMap();
|
||||
ENSURE(heightmap_source.size() == (std::size_t) SQR(g_Game->GetWorld()->GetTerrain().GetVerticesPerSide()));
|
||||
std::copy(heightmap_source.begin(), heightmap_source.end(), heightmap);
|
||||
|
||||
@@ -455,7 +455,7 @@ BEGIN_COMMAND(ResizeMap)
|
||||
ssize_t m_OldPatches, m_NewPatches;
|
||||
int m_OffsetX, m_OffsetY;
|
||||
|
||||
u16* m_Heightmap;
|
||||
std::uint16_t* m_Heightmap;
|
||||
CPatch* m_Patches;
|
||||
|
||||
std::vector<DeletedObject> m_DeletedObjects;
|
||||
@@ -562,7 +562,7 @@ BEGIN_COMMAND(ResizeMap)
|
||||
m_OffsetY = -(msg->offsetY / PATCH_SIZE);
|
||||
|
||||
CTerrain* terrain = cmpTerrain->GetCTerrain();
|
||||
m_Heightmap = new u16[(m_OldPatches * PATCH_SIZE + 1) * (m_OldPatches * PATCH_SIZE + 1)];
|
||||
m_Heightmap = new std::uint16_t[(m_OldPatches * PATCH_SIZE + 1) * (m_OldPatches * PATCH_SIZE + 1)];
|
||||
std::copy_n(terrain->GetHeightMap(), (m_OldPatches * PATCH_SIZE + 1) * (m_OldPatches * PATCH_SIZE + 1), m_Heightmap);
|
||||
m_Patches = new CPatch[m_OldPatches * m_OldPatches];
|
||||
for (ssize_t j = 0; j < m_OldPatches; ++j)
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "gui/GUIManager.h"
|
||||
#include "lib/external_libraries/libsdl.h"
|
||||
#include "lib/path.h"
|
||||
#include "lib/types.h"
|
||||
#include "maths/MathUtil.h"
|
||||
#include "ps/Game.h"
|
||||
#include "ps/GameSetup/Config.h"
|
||||
@@ -128,8 +127,8 @@ MESSAGEHANDLER(GuiMouseButtonEvent)
|
||||
ev.button.clicks = msg->clicks;
|
||||
float x, y;
|
||||
msg->pos->GetScreenSpace(x, y);
|
||||
ev.button.x = static_cast<u16>(Clamp<int>(x, 0, g_VideoMode.GetWindowWidth()));
|
||||
ev.button.y = static_cast<u16>(Clamp<int>(y, 0, g_VideoMode.GetWindowHeight()));
|
||||
ev.button.x = static_cast<std::uint16_t>(Clamp<int>(x, 0, g_VideoMode.GetWindowWidth()));
|
||||
ev.button.y = static_cast<std::uint16_t>(Clamp<int>(y, 0, g_VideoMode.GetWindowHeight()));
|
||||
g_VideoMode.m_InputManager.DispatchEvent(ev);
|
||||
}
|
||||
|
||||
@@ -142,8 +141,8 @@ MESSAGEHANDLER(GuiMouseMotionEvent)
|
||||
ev.type = SDL_MOUSEMOTION;
|
||||
float x, y;
|
||||
msg->pos->GetScreenSpace(x, y);
|
||||
ev.motion.x = static_cast<u16>(Clamp<int>(x, 0, g_VideoMode.GetWindowWidth()));
|
||||
ev.motion.y = static_cast<u16>(Clamp<int>(y, 0, g_VideoMode.GetWindowHeight()));
|
||||
ev.motion.x = static_cast<std::uint16_t>(Clamp<int>(x, 0, g_VideoMode.GetWindowWidth()));
|
||||
ev.motion.y = static_cast<std::uint16_t>(Clamp<int>(y, 0, g_VideoMode.GetWindowHeight()));
|
||||
g_VideoMode.m_InputManager.DispatchEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -542,19 +542,19 @@ BEGIN_COMMAND(FillTerrain)
|
||||
// Simple 4-way flood fill algorithm using queue and a grid to keep track of visited tiles,
|
||||
// almost as fast as loop for filling whole map, much faster for small patches
|
||||
SparseGrid<bool> visited(tiles, tiles);
|
||||
std::queue<std::pair<u16, u16> > queue;
|
||||
std::queue<std::pair<std::uint16_t, std::uint16_t>> queue;
|
||||
|
||||
// Initial tile
|
||||
queue.push(std::make_pair((u16)x0, (u16)y0));
|
||||
queue.push(std::make_pair(static_cast<std::uint16_t>(x0), static_cast<std::uint16_t>(y0)));
|
||||
visited.set(x0, y0, true);
|
||||
|
||||
while(!queue.empty())
|
||||
{
|
||||
// Check front of queue
|
||||
std::pair<u16, u16> t = queue.front();
|
||||
std::pair<std::uint16_t, std::uint16_t> t = queue.front();
|
||||
queue.pop();
|
||||
u16 i = t.first;
|
||||
u16 j = t.second;
|
||||
std::uint16_t i = t.first;
|
||||
std::uint16_t j = t.second;
|
||||
|
||||
if (m_TerrainDelta.GetTexEntry(i, j) == replacedTex)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,7 @@ unknownMacro:source/lib/sysdep/os/win/wdbg_sym.cpp
|
||||
unknownMacro:source/lib/sysdep/os/win/wfirmware.cpp
|
||||
unknownMacro:source/lib/sysdep/os/win/wposix/wutsname.cpp
|
||||
unknownMacro:source/ps/CStr.cpp
|
||||
unknownMacro:source/simulation2/components/tests/test_HierPathfinder.h
|
||||
|
||||
uninitvar:source/ps/Game.cpp
|
||||
uninitvar:source/ps/scripting/JSInterface_SavedGame.cpp
|
||||
|
||||
Reference in new issue
Block a user