Browse Source

Clang-tidy: readability-identifier-naming.MemberCase: camelBack

pull/2297/head
Anders Jenbo 5 years ago
parent
commit
372b1dcba2
  1. 1
      Source/.clang-tidy
  2. 30
      Source/DiabloUI/credits.cpp
  3. 6
      Source/codec.cpp
  4. 44
      Source/controls/touch.cpp
  5. 20
      Source/utils/language.cpp

1
Source/.clang-tidy

@ -60,6 +60,7 @@ CheckOptions:
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
- { key: readability-identifier-naming.ParameterCase, value: camelBack }
- { key: readability-identifier-naming.MemberCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
- { key: readability-identifier-naming.GlobalVariableCase, value: aNy_CasE }

30
Source/DiabloUI/credits.cpp

@ -38,20 +38,20 @@ struct CachedLine {
CachedLine()
{
m_index = 0;
palette_version = pal_surface_palette_version;
mIndex = 0;
paletteVersion = pal_surface_palette_version;
}
CachedLine(std::size_t index, SDLSurfaceUniquePtr surface)
{
m_index = index;
m_surface = std::move(surface);
palette_version = pal_surface_palette_version;
mIndex = index;
mSurface = std::move(surface);
paletteVersion = pal_surface_palette_version;
}
std::size_t m_index;
SDLSurfaceUniquePtr m_surface;
unsigned int palette_version;
std::size_t mIndex;
SDLSurfaceUniquePtr mSurface;
unsigned int paletteVersion;
};
SDL_Surface *RenderText(const char *text, SDL_Color color)
@ -172,24 +172,24 @@ void CreditsRenderer::Render()
Sint16 destY = UI_OFFSET_Y + VIEWPORT.y - (offsetY - linesBegin * LINE_H);
for (std::size_t i = linesBegin; i < linesEnd; ++i, destY += LINE_H) {
CachedLine &line = lines_[i];
if (line.m_surface == nullptr)
if (line.mSurface == nullptr)
continue;
// Still fading in: the cached line was drawn with a different fade level.
if (line.palette_version != pal_surface_palette_version) {
line = PrepareLine(line.m_index);
if (line.paletteVersion != pal_surface_palette_version) {
line = PrepareLine(line.mIndex);
}
Sint16 destX = PANEL_LEFT + VIEWPORT.x + 31;
int j = 0;
while (text[line.m_index][j++] == '\t')
while (text[line.mIndex][j++] == '\t')
destX += 40;
SDL_Rect dstRect = { destX, destY, 0, 0 };
ScaleOutputRect(&dstRect);
dstRect.w = line.m_surface->w;
dstRect.h = line.m_surface->h;
if (SDL_BlitSurface(line.m_surface.get(), nullptr, DiabloUiSurface(), &dstRect) < 0)
dstRect.w = line.mSurface->w;
dstRect.h = line.mSurface->h;
if (SDL_BlitSurface(line.mSurface.get(), nullptr, DiabloUiSurface(), &dstRect) < 0)
ErrSdl();
}
SDL_SetClipRect(DiabloUiSurface(), nullptr);

6
Source/codec.cpp

@ -16,7 +16,7 @@ namespace devilution {
struct CodecSignature {
uint32_t checksum;
uint8_t error;
uint8_t last_chunk_size;
uint8_t lastChunkSize;
uint16_t unused;
};
@ -90,7 +90,7 @@ std::size_t codec_decode(byte *pbSrcDst, std::size_t size, const char *pszPasswo
goto error;
}
size += sig->last_chunk_size - BLOCKSIZE;
size += sig->lastChunkSize - BLOCKSIZE;
SHA1Clear();
return size;
error:
@ -138,7 +138,7 @@ void codec_encode(byte *pbSrcDst, std::size_t size, std::size_t size64, const ch
sig->error = 0;
sig->unused = 0;
sig->checksum = *(uint32_t *)&tmp[0];
sig->last_chunk_size = lastChunk;
sig->lastChunkSize = lastChunk;
SHA1Clear();
}

44
Source/controls/touch.cpp

@ -54,11 +54,11 @@ enum {
struct Touch {
int id; // -1: not touching
uint32_t time_last_down;
int last_x; // last known screen coordinates
int last_y; // last known screen coordinates
float last_down_x; // SDL touch coordinates when last pressed down
float last_down_y; // SDL touch coordinates when last pressed down
uint32_t timeLastDown;
int lastX; // last known screen coordinates
int lastY; // last known screen coordinates
float lastDownX; // SDL touch coordinates when last pressed down
float lastDownY; // SDL touch coordinates when last pressed down
};
static Touch finger[TOUCH_PORT_MAX_NUM][MaxNumFingers]; // keep track of finger status
@ -169,11 +169,11 @@ static void PreprocessFingerDown(SDL_Event *event)
continue;
}
finger[port][i].id = id;
finger[port][i].time_last_down = event->tfinger.timestamp;
finger[port][i].last_down_x = event->tfinger.x;
finger[port][i].last_down_y = event->tfinger.y;
finger[port][i].last_x = x;
finger[port][i].last_y = y;
finger[port][i].timeLastDown = event->tfinger.timestamp;
finger[port][i].lastDownX = event->tfinger.x;
finger[port][i].lastDownY = event->tfinger.y;
finger[port][i].lastX = x;
finger[port][i].lastY = y;
break;
}
}
@ -242,14 +242,14 @@ static void PreprocessFingerUp(SDL_Event *event)
finger[port][i].id = NO_TOUCH;
if (multi_finger_dragging[port] == DragNone) {
if ((event->tfinger.timestamp - finger[port][i].time_last_down) > MaxTapTime) {
if ((event->tfinger.timestamp - finger[port][i].timeLastDown) > MaxTapTime) {
continue;
}
// short (<MAX_TAP_TIME ms) tap is interpreted as right/left mouse click depending on # fingers already down
// but only if the finger hasn't moved since it was pressed down by more than MAX_TAP_MOTION_DISTANCE pixels
float xrel = ((event->tfinger.x * devilution::GetOutputSurface()->w) - (finger[port][i].last_down_x * devilution::GetOutputSurface()->w));
float yrel = ((event->tfinger.y * devilution::GetOutputSurface()->h) - (finger[port][i].last_down_y * devilution::GetOutputSurface()->h));
float xrel = ((event->tfinger.x * devilution::GetOutputSurface()->w) - (finger[port][i].lastDownX * devilution::GetOutputSurface()->w));
float yrel = ((event->tfinger.y * devilution::GetOutputSurface()->h) - (finger[port][i].lastDownY * devilution::GetOutputSurface()->h));
auto maxRSquared = static_cast<float>(MaxTapMotionDistance * MaxTapMotionDistance);
if ((xrel * xrel + yrel * yrel) >= maxRSquared) {
continue;
@ -337,8 +337,8 @@ static void PreprocessFingerMotion(SDL_Event *event)
for (int i = 0; i < MaxNumFingers; i++) {
if (finger[port][i].id != id)
continue;
finger[port][i].last_x = x;
finger[port][i].last_y = y;
finger[port][i].lastX = x;
finger[port][i].lastY = y;
}
// If we are starting a multi-finger drag, start holding down the mouse button
@ -349,7 +349,7 @@ static void PreprocessFingerMotion(SDL_Event *event)
if (finger[port][i].id == NO_TOUCH) {
continue;
}
if (event->tfinger.timestamp - finger[port][i].time_last_down > MaxTapTime) {
if (event->tfinger.timestamp - finger[port][i].timeLastDown > MaxTapTime) {
numFingersDownlong++;
}
}
@ -359,13 +359,13 @@ static void PreprocessFingerMotion(SDL_Event *event)
if (direct_touch) {
for (int i = 0; i < MaxNumFingers; i++) {
if (finger[port][i].id == id) {
uint32_t earliestTime = finger[port][i].time_last_down;
uint32_t earliestTime = finger[port][i].timeLastDown;
for (int j = 0; j < MaxNumFingers; j++) {
if (finger[port][j].id >= 0 && (i != j)) {
if (finger[port][j].time_last_down < earliestTime) {
mouseDownX = finger[port][j].last_x;
mouseDownY = finger[port][j].last_y;
earliestTime = finger[port][j].time_last_down;
if (finger[port][j].timeLastDown < earliestTime) {
mouseDownX = finger[port][j].lastX;
mouseDownY = finger[port][j].lastY;
earliestTime = finger[port][j].timeLastDown;
}
}
}
@ -404,7 +404,7 @@ static void PreprocessFingerMotion(SDL_Event *event)
if (finger[port][j].id == NO_TOUCH || (j == i)) {
continue;
}
if (finger[port][j].time_last_down < finger[port][i].time_last_down) {
if (finger[port][j].timeLastDown < finger[port][i].timeLastDown) {
updatePointer = false;
}
}

20
Source/utils/language.cpp

@ -32,9 +32,9 @@ struct MoHead {
uint16_t minor;
} revision;
uint32_t nb_mappings;
uint32_t src_offset;
uint32_t dst_offset;
uint32_t nbMappings;
uint32_t srcOffset;
uint32_t dstOffset;
};
struct MoEntry {
@ -263,19 +263,19 @@ void LanguageInitialize()
}
// Read entries of source strings
std::unique_ptr<MoEntry[]> src { new MoEntry[head.nb_mappings] };
if (fseek(fp, head.src_offset, SEEK_SET) != 0)
std::unique_ptr<MoEntry[]> src { new MoEntry[head.nbMappings] };
if (fseek(fp, head.srcOffset, SEEK_SET) != 0)
return;
// FIXME: Endianness.
if (fread(src.get(), sizeof(MoEntry), head.nb_mappings, fp) != head.nb_mappings)
if (fread(src.get(), sizeof(MoEntry), head.nbMappings, fp) != head.nbMappings)
return;
// Read entries of target strings
std::unique_ptr<MoEntry[]> dst { new MoEntry[head.nb_mappings] };
if (fseek(fp, head.dst_offset, SEEK_SET) != 0)
std::unique_ptr<MoEntry[]> dst { new MoEntry[head.nbMappings] };
if (fseek(fp, head.dstOffset, SEEK_SET) != 0)
return;
// FIXME: Endianness.
if (fread(dst.get(), sizeof(MoEntry), head.nb_mappings, fp) != head.nb_mappings)
if (fread(dst.get(), sizeof(MoEntry), head.nbMappings, fp) != head.nbMappings)
return;
std::vector<char> key;
@ -295,7 +295,7 @@ void LanguageInitialize()
translation[i] = {};
// Read strings described by entries
for (uint32_t i = 1; i < head.nb_mappings; i++) {
for (uint32_t i = 1; i < head.nbMappings; i++) {
if (ReadEntry(fp, &src[i], key) && ReadEntry(fp, &dst[i], value)) {
size_t offset = 0;
for (int j = 0; j < PluralForms; j++) {

Loading…
Cancel
Save