Skip to content

Commit

Permalink
Remove explicit void in functions with no parameters (#744)
Browse files Browse the repository at this point in the history
Resolves #698
  • Loading branch information
Kenix3 authored Dec 12, 2024
1 parent f81a1db commit 18fa965
Show file tree
Hide file tree
Showing 29 changed files with 144 additions and 144 deletions.
4 changes: 2 additions & 2 deletions src/audio/AudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ AudioPlayer::~AudioPlayer() {
SPDLOG_TRACE("destruct audio player");
}

bool AudioPlayer::Init(void) {
bool AudioPlayer::Init() {
mInitialized = DoInit();
return IsInitialized();
}

bool AudioPlayer::IsInitialized(void) {
bool AudioPlayer::IsInitialized() {
return mInitialized;
}

Expand Down
8 changes: 4 additions & 4 deletions src/audio/AudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class AudioPlayer {
}
~AudioPlayer();

bool Init(void);
virtual int32_t Buffered(void) = 0;
bool Init();
virtual int32_t Buffered() = 0;
virtual void Play(const uint8_t* buf, size_t len) = 0;

bool IsInitialized(void);
bool IsInitialized();

int32_t GetSampleRate() const;

Expand All @@ -37,7 +37,7 @@ class AudioPlayer {
void SetDesiredBuffered(int32_t size);

protected:
virtual bool DoInit(void) = 0;
virtual bool DoInit() = 0;

private:
bool mInitialized = false;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/SDLAudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SDLAudioPlayer::~SDLAudioPlayer() {
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}

bool SDLAudioPlayer::DoInit(void) {
bool SDLAudioPlayer::DoInit() {
if (SDL_Init(SDL_INIT_AUDIO) != 0) {
SPDLOG_ERROR("SDL init error: %s\n", SDL_GetError());
return false;
Expand All @@ -29,7 +29,7 @@ bool SDLAudioPlayer::DoInit(void) {
return true;
}

int SDLAudioPlayer::Buffered(void) {
int SDLAudioPlayer::Buffered() {
// 4 is sizeof(int16_t) * num_channels (2 for stereo)
return SDL_GetQueuedAudioSize(mDevice) / 4;
}
Expand Down
4 changes: 2 additions & 2 deletions src/audio/SDLAudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class SDLAudioPlayer : public AudioPlayer {
}
~SDLAudioPlayer();

int Buffered(void);
int Buffered();
void Play(const uint8_t* buf, size_t len);

protected:
bool DoInit(void);
bool DoInit();

private:
SDL_AudioDeviceID mDevice;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/WasapiAudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void WasapiAudioPlayer::ThrowIfFailed(HRESULT res) {
}
}

bool WasapiAudioPlayer::SetupStream(void) {
bool WasapiAudioPlayer::SetupStream() {
try {
ThrowIfFailed(mDeviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &mDevice));
ThrowIfFailed(mDevice->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr, IID_PPV_ARGS_Helper(&mClient)));
Expand Down Expand Up @@ -51,7 +51,7 @@ bool WasapiAudioPlayer::SetupStream(void) {
return true;
}

bool WasapiAudioPlayer::DoInit(void) {
bool WasapiAudioPlayer::DoInit() {
try {
ThrowIfFailed(
CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&mDeviceEnumerator)));
Expand All @@ -62,7 +62,7 @@ bool WasapiAudioPlayer::DoInit(void) {
return true;
}

int WasapiAudioPlayer::Buffered(void) {
int WasapiAudioPlayer::Buffered() {
if (!mInitialized) {
if (!SetupStream()) {
return 0;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/WasapiAudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WasapiAudioPlayer : public AudioPlayer, public IMMNotificationClient {
WasapiAudioPlayer(AudioSettings settings) : AudioPlayer(settings) {
}

int Buffered(void);
int Buffered();
void Play(const uint8_t* buf, size_t len);

protected:
Expand All @@ -28,8 +28,8 @@ class WasapiAudioPlayer : public AudioPlayer, public IMMNotificationClient {
virtual ULONG STDMETHODCALLTYPE Release();
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID** ppvInterface);
void ThrowIfFailed(HRESULT res);
bool SetupStream(void);
bool DoInit(void);
bool SetupStream();
bool DoInit();

private:
ComPtr<IMMDeviceEnumerator> mDeviceEnumerator;
Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Fast3D/Fast3dWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ bool Fast3dWindow::KeyDown(int32_t scancode) {
return isProcessed;
}

void Fast3dWindow::AllKeysUp(void) {
void Fast3dWindow::AllKeysUp() {
Ship::Context::GetInstance()->GetControlDeck()->ProcessKeyboardEvent(Ship::KbEventType::LUS_KB_EVENT_ALL_KEYS_UP,
Ship::KbScancode::LUS_KB_UNKNOWN);
}
Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Fast3D/Fast3dWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Fast3dWindow : public Ship::Window {
protected:
static bool KeyDown(int32_t scancode);
static bool KeyUp(int32_t scancode);
static void AllKeysUp(void);
static void AllKeysUp();
static void OnFullscreenChanged(bool isNowFullscreen);

private:
Expand Down
22 changes: 11 additions & 11 deletions src/graphic/Fast3D/gfx_direct3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static struct {

static LARGE_INTEGER last_time, accumulated_time, frequency;

int gfx_d3d11_create_framebuffer(void);
int gfx_d3d11_create_framebuffer();

static void create_depth_stencil_objects(uint32_t width, uint32_t height, uint32_t msaa_count,
ID3D11DepthStencilView** view, ID3D11ShaderResourceView** srv) {
Expand Down Expand Up @@ -207,7 +207,7 @@ static void create_depth_stencil_objects(uint32_t width, uint32_t height, uint32
}
}

static void gfx_d3d11_init(void) {
static void gfx_d3d11_init() {
// Load d3d11.dll
d3d.d3d11_module = LoadLibraryW(L"d3d11.dll");
if (d3d.d3d11_module == nullptr) {
Expand Down Expand Up @@ -399,7 +399,7 @@ static const char* gfx_d3d11_get_name() {
return "DirectX 11";
}

static struct GfxClipParameters gfx_d3d11_get_clip_parameters(void) {
static struct GfxClipParameters gfx_d3d11_get_clip_parameters() {
return { true, false };
}

Expand Down Expand Up @@ -559,7 +559,7 @@ static void gfx_d3d11_shader_get_info(struct ShaderProgram* prg, uint8_t* num_in
used_textures[1] = p->used_textures[1];
}

static uint32_t gfx_d3d11_new_texture(void) {
static uint32_t gfx_d3d11_new_texture() {
d3d.textures.resize(d3d.textures.size() + 1);
return (uint32_t)(d3d.textures.size() - 1);
}
Expand Down Expand Up @@ -810,11 +810,11 @@ static void gfx_d3d11_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t
d3d.context->Draw(buf_vbo_num_tris * 3, 0);
}

static void gfx_d3d11_on_resize(void) {
static void gfx_d3d11_on_resize() {
// create_render_target_views(true);
}

static void gfx_d3d11_start_frame(void) {
static void gfx_d3d11_start_frame() {
// Set per-frame constant buffer
ID3D11Buffer* buffers[2] = { d3d.per_frame_cb.Get(), d3d.per_draw_cb.Get() };
d3d.context->PSSetConstantBuffers(0, 2, buffers);
Expand All @@ -826,15 +826,15 @@ static void gfx_d3d11_start_frame(void) {
}
}

static void gfx_d3d11_end_frame(void) {
static void gfx_d3d11_end_frame() {
d3d.context->Flush();
}

static void gfx_d3d11_finish_render(void) {
static void gfx_d3d11_finish_render() {
d3d.context->Flush();
}

int gfx_d3d11_create_framebuffer(void) {
int gfx_d3d11_create_framebuffer() {
uint32_t texture_id = gfx_d3d11_new_texture();
TextureData& t = d3d.textures[texture_id];

Expand Down Expand Up @@ -1112,7 +1112,7 @@ void gfx_d3d11_set_texture_filter(FilteringMode mode) {
gfx_texture_cache_clear();
}

FilteringMode gfx_d3d11_get_texture_filter(void) {
FilteringMode gfx_d3d11_get_texture_filter() {
return d3d.current_filter_mode;
}

Expand Down Expand Up @@ -1233,7 +1233,7 @@ ImTextureID gfx_d3d11_get_texture_by_id(int id) {
return d3d.textures[id].resource_view.Get();
}

void gfx_d3d11_enable_srgb_mode(void) {
void gfx_d3d11_enable_srgb_mode() {
d3d.srgb_mode = true;
}

Expand Down
18 changes: 9 additions & 9 deletions src/graphic/Fast3D/gfx_direct3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static D3D12_RESOURCE_ALLOCATION_INFO get_resource_allocation_info(const D3D12_R
#endif
}

static bool gfx_direct3d12_z_is_from_0_to_1(void) {
static bool gfx_direct3d12_z_is_from_0_to_1() {
return true;
}

Expand Down Expand Up @@ -291,7 +291,7 @@ static void gfx_direct3d12_shader_get_info(struct ShaderProgram* prg, uint8_t* n
used_textures[1] = p->used_textures[1];
}

static uint32_t gfx_direct3d12_new_texture(void) {
static uint32_t gfx_direct3d12_new_texture() {
d3d.textures.resize(d3d.textures.size() + 1);
return (uint32_t)(d3d.textures.size() - 1);
}
Expand Down Expand Up @@ -615,7 +615,7 @@ static void gfx_direct3d12_draw_triangles(float buf_vbo[], size_t buf_vbo_len, s
d3d.command_list->DrawInstanced(3 * buf_vbo_num_tris, 1, 0, 0);
}

static void gfx_direct3d12_start_frame(void) {
static void gfx_direct3d12_start_frame() {
++d3d.frame_counter;
d3d.srv_pos = 0;
texture_uploads = 0;
Expand Down Expand Up @@ -649,7 +649,7 @@ static void gfx_direct3d12_start_frame(void) {
d3d.vbuf_pos = 0;
}

static void create_render_target_views(void) {
static void create_render_target_views() {
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle = get_cpu_descriptor_handle(d3d.rtv_heap);
for (UINT i = 0; i < 2; i++) {
ThrowIfFailed(d3d.swap_chain->GetBuffer(i, IID_ID3D12Resource, (void**)&d3d.render_targets[i]));
Expand All @@ -658,7 +658,7 @@ static void create_render_target_views(void) {
}
}

static void create_depth_buffer(void) {
static void create_depth_buffer() {
DXGI_SWAP_CHAIN_DESC1 desc1;
ThrowIfFailed(d3d.swap_chain->GetDesc1(&desc1));
UINT width = desc1.Width;
Expand Down Expand Up @@ -702,7 +702,7 @@ static void create_depth_buffer(void) {
get_cpu_descriptor_handle(d3d.dsv_heap));
}

static void gfx_direct3d12_on_resize(void) {
static void gfx_direct3d12_on_resize() {
if (d3d.render_targets[0].Get() != nullptr) {
d3d.render_targets[0].Reset();
d3d.render_targets[1].Reset();
Expand All @@ -714,7 +714,7 @@ static void gfx_direct3d12_on_resize(void) {
}
}

static void gfx_direct3d12_init(void) {
static void gfx_direct3d12_init() {
// Load d3d12.dll
d3d.d3d12_module = LoadLibraryW(L"d3d12.dll");
if (d3d.d3d12_module == nullptr) {
Expand Down Expand Up @@ -897,7 +897,7 @@ static void gfx_direct3d12_init(void) {
}
}

static void gfx_direct3d12_end_frame(void) {
static void gfx_direct3d12_end_frame() {
if (max_texture_uploads < texture_uploads && texture_uploads != 38 && texture_uploads != 34 &&
texture_uploads != 29) {
max_texture_uploads = texture_uploads;
Expand Down Expand Up @@ -932,7 +932,7 @@ static void gfx_direct3d12_end_frame(void) {
}
}

static void gfx_direct3d12_finish_render(void) {
static void gfx_direct3d12_finish_render() {
LARGE_INTEGER t0, t1, t2;
QueryPerformanceCounter(&t0);

Expand Down
24 changes: 12 additions & 12 deletions src/graphic/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ static struct {
void (*on_fullscreen_changed)(bool is_now_fullscreen);
bool (*on_key_down)(int scancode);
bool (*on_key_up)(int scancode);
void (*on_all_keys_up)(void);
void (*on_all_keys_up)();
} dxgi;

static void load_dxgi_library(void) {
static void load_dxgi_library() {
dxgi.dxgi_module = LoadLibraryW(L"dxgi.dll");
*(FARPROC*)&dxgi.CreateDXGIFactory1 = GetProcAddress(dxgi.dxgi_module, "CreateDXGIFactory1");
*(FARPROC*)&dxgi.CreateDXGIFactory2 = GetProcAddress(dxgi.dxgi_module, "CreateDXGIFactory2");
Expand Down Expand Up @@ -568,7 +568,7 @@ static void gfx_dxgi_get_active_window_refresh_rate(uint32_t* refresh_rate) {
}

static void gfx_dxgi_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bool (*on_key_up)(int scancode),
void (*on_all_keys_up)(void)) {
void (*on_all_keys_up)()) {
dxgi.on_key_down = on_key_down;
dxgi.on_key_up = on_key_up;
dxgi.on_all_keys_up = on_all_keys_up;
Expand All @@ -581,7 +581,7 @@ static void gfx_dxgi_get_dimensions(uint32_t* width, uint32_t* height, int32_t*
*posY = dxgi.posY;
}

static void gfx_dxgi_handle_events(void) {
static void gfx_dxgi_handle_events() {
MSG msg;
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
Expand All @@ -602,7 +602,7 @@ static uint64_t qpc_to_100ns(uint64_t qpc) {
qpc % dxgi.qpc_freq * _100NANOSECONDS_IN_SECOND / dxgi.qpc_freq;
}

static bool gfx_dxgi_start_frame(void) {
static bool gfx_dxgi_start_frame() {
DXGI_FRAME_STATISTICS stats;
if (dxgi.swap_chain->GetFrameStatistics(&stats) == S_OK &&
(stats.SyncRefreshCount != 0 || stats.SyncQPCTime.QuadPart != 0ULL)) {
Expand Down Expand Up @@ -749,7 +749,7 @@ static bool gfx_dxgi_start_frame(void) {
return true;
}

static void gfx_dxgi_swap_buffers_begin(void) {
static void gfx_dxgi_swap_buffers_begin() {
LARGE_INTEGER t;
dxgi.use_timer = true;
if (dxgi.use_timer || (dxgi.tearing_support && !dxgi.is_vsync_enabled)) {
Expand Down Expand Up @@ -801,7 +801,7 @@ static void gfx_dxgi_swap_buffers_begin(void) {
dxgi.dropped_frame = false;
}

static void gfx_dxgi_swap_buffers_end(void) {
static void gfx_dxgi_swap_buffers_end() {
LARGE_INTEGER t0, t1, t2;
QueryPerformanceCounter(&t0);
QueryPerformanceCounter(&t1);
Expand Down Expand Up @@ -846,7 +846,7 @@ static void gfx_dxgi_swap_buffers_end(void) {
// stats.SyncRefreshCount, (unsigned long long)(stats.SyncQPCTime.QuadPart - dxgi.qpc_init));
}

static double gfx_dxgi_get_time(void) {
static double gfx_dxgi_get_time() {
LARGE_INTEGER t;
QueryPerformanceCounter(&t);
return (double)(t.QuadPart - dxgi.qpc_init) / dxgi.qpc_freq;
Expand Down Expand Up @@ -933,11 +933,11 @@ void gfx_dxgi_create_swap_chain(IUnknown* device, std::function<void()>&& before
dxgi.before_destroy_swap_chain_fn = std::move(before_destroy_fn);
}

bool gfx_dxgi_is_running(void) {
bool gfx_dxgi_is_running() {
return dxgi.is_running;
}

HWND gfx_dxgi_get_h_wnd(void) {
HWND gfx_dxgi_get_h_wnd() {
return dxgi.h_wnd;
}

Expand Down Expand Up @@ -971,11 +971,11 @@ bool gfx_dxgi_can_disable_vsync() {
return dxgi.tearing_support;
}

void gfx_dxgi_destroy(void) {
void gfx_dxgi_destroy() {
// TODO: destroy _any_ resources used by dxgi, including the window handle
}

bool gfx_dxgi_is_fullscreen(void) {
bool gfx_dxgi_is_fullscreen() {
return dxgi.is_full_screen;
}

Expand Down
Loading

0 comments on commit 18fa965

Please sign in to comment.