remove unused code (mainly windows.h)

This commit is contained in:
Edu García 2024-05-07 22:37:06 +01:00
parent aaa0d21b87
commit 3440667e93
40 changed files with 23 additions and 1621 deletions

View File

@ -92,13 +92,18 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_compile_definitions(__LINUX__ LINUX _MAX_PATH=260 _MAX_FNAME=256 _REENRANT MACOSX=1 _USE_OGL_ACTIVE_TEXTURES)
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows.h defines to avoid as many issues as possible.
add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX NODRAWTEXT NOBITMAP NOMCX NOSERVICE NOHELP
#[[NOGDI]] # We need GDI for now, enable when GDI is actually not needed (or when all windows.h mentions are gone)
)
list(APPEND CMAKE_LIBRARY_PATH "lib/win" "lib/win/directx")
add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>>:/EHsc;/RTC1;/W3;/nologo;/c;/Zi;/TP;/errorReport:prompt>")
add_compile_options("$<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUAGE:CXX>>:/GL;/FD;/EHsc;/W3;/nologo;/c;/Zi;/TP;/errorReport:prompt>")
string(APPEND CMAKE_EXE_LINKER_FLAGS " /SAFESEH:NO /NODEFAULTLIB:LIBC")
set(CMAKE_MODULE_LINKER_FLAGS "/SAFESEH:NO /NODEFAULTLIB:LIBC")
add_compile_definitions(IS_WINDOWS _CRT_SECURE_NO_WARNINGS WIN32 _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE NOMINMAX)
add_compile_definitions(IS_WINDOWS _CRT_SECURE_NO_WARNINGS WIN32 _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE)
set(PLATFORM_INCLUDES "lib/win/directx" "lib/win")

View File

@ -94,9 +94,7 @@
#include <math.h>
#include "psrand.h"
#if defined(WIN32)
#include <windows.h>
#elif defined(__LINUX__)
#if defined(__LINUX__)
#include "linux/linux_fix.h"
#endif

View File

@ -276,10 +276,6 @@
*
* $NoKeywords: $
*/
#ifdef WIN32
#include <crtdbg.h>
#include "windows.h"
#endif
#include "ui.h"
#include "newui.h"
#include "game.h"
@ -289,12 +285,9 @@
#include "manage.h"
#include "Mission.h"
#include "pilot.h"
#include "ui.h"
#include "newui.h"
#include "pstypes.h"
#include "pserror.h"
#include "descent.h"
#include "game.h"
#include "room.h"
#include "object.h"
#include "terrain.h"
@ -310,14 +303,12 @@
#include "DllWrappers.h"
#include "appdatabase.h"
#include "module.h"
#include "ship.h"
#include "localization.h"
#include "stringtable.h"
#include "dedicated_server.h"
#include "multi_save_settings.h"
#include "multi_dll_mgr.h"
#include "mission_download.h"
#include "module.h"
#include "mem.h"
#include "args.h"
// #define USE_DIRECTPLAY

View File

@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

View File

@ -39,7 +39,6 @@
#ifndef DDGRWIN32DX_H
#define DDGRWIN32DX_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "ddgr.h"

View File

@ -39,7 +39,6 @@
#ifndef DDGRWIN32GDI_H
#define DDGRWIN32GDI_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "ddgr.h"

View File

@ -7,7 +7,6 @@ set(HEADERS
Ia3dutil.h
vmanpset.h)
set(CPPS
aureal3d.cpp
ddsoundload.cpp
Ds3dlib.cpp
dsound3d.cpp

View File

@ -77,6 +77,8 @@
#ifndef AUDDEV_H
#define AUDDEV_H
#include <windows.h>
#include <mmsystem.h>
#include "dsound.h"
#include "vmanpset.h"
#include "pstypes.h"

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,6 @@
#ifndef DS3DLIB_INTERNAL_H
#define DS3DLIB_INTERNAL_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>

View File

@ -46,7 +46,6 @@
#include "ddvid.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddraw.h>
#include <stdlib.h>

View File

@ -192,13 +192,8 @@
#include "Debug.h"
#include "mono.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winioctl.h>
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
///////////////////////////////////////////////////////////////////////////////

View File

@ -24,7 +24,6 @@
#include "Debug.h"
#include "networking.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winioctl.h>
#include <assert.h>

View File

@ -146,8 +146,6 @@
#include "ddio_win.h"
#include "pserror.h"
#include "mem.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdarg.h>
#include <sys\stat.h>
#include <io.h>

View File

@ -106,7 +106,6 @@
#include "Macros.h"
#include "logfile.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#include <regstr.h>

View File

@ -25,6 +25,9 @@
#include "pserror.h"
#include "mono.h"
#include <windows.h>
#include <mmsystem.h>
#define MAX_TIMER_HOOKS 4
#define TIMER_CLOCK_RATE 100 // ms

View File

@ -28,8 +28,6 @@
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>

View File

@ -51,10 +51,6 @@
#if defined(WIN32)
// Headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// Messages
#define WM_SYNCMOUSEACQUIRE (WM_USER + 0)

View File

@ -17,7 +17,6 @@
*/
#if _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <MMSystem.h>

View File

@ -143,10 +143,6 @@
*
* $NoKeywords: $
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include "cfile.h"
#include "manage.h"
#include "door.h"

View File

@ -16,10 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include "cfile.h"
#include "manage.h"
#include "mono.h"

View File

@ -351,10 +351,6 @@
*
* $NoKeywords: $
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include "cfile.h"
#include "manage.h"
#include "genericpage.h"

View File

@ -440,9 +440,7 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#if defined(WIN32)
#include <windows.h>
#elif defined(__LINUX__)
#if defined(__LINUX__)
#include "linux/linux_fix.h"
#endif
#include "descent.h"

View File

@ -61,9 +61,7 @@
* $NoKeywords: $
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include <cstring>
#include "cfile.h"
#include "manage.h"
#include "megacell.h"
@ -73,9 +71,6 @@
#include "pserror.h"
#include "polymodel.h"
#include "ddio.h"
#if defined(LINUX)
#include <string.h>
#endif
// megacellpage commands that are read/written
// A command is followed by a byte count describing how many bytes
// are in the data for the command

View File

@ -197,10 +197,6 @@
*
* $NoKeywords: $
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include "cfile.h"
#include "manage.h"
#include "ship.h"

View File

@ -117,9 +117,6 @@
*
* $NoKeywords: $
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include "cfile.h"
#include "manage.h"
#include "soundpage.h"

View File

@ -257,10 +257,6 @@
* $NoKeywords: $
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include "cfile.h"
#include "manage.h"
#include "gametexture.h"

View File

@ -286,10 +286,6 @@
*
* $NoKeywords: $
*/
#if defined(WIN32)
#include <windows.h>
#endif
#include "cfile.h"
#include "manage.h"
#include "weapon.h"

View File

@ -29,7 +29,8 @@
#include "DDAccess.h"
#ifdef WIN32
#include <MMSystem.h>
#include <windows.h>
#include <mmsystem.h>
#include <io.h>
#include "dsound.h"
#endif

View File

@ -75,6 +75,10 @@
#define FTP_STATE_CANT_WRITE_FILE 15
#define FTP_STATE_STARTUP 16
#if WIN32
typedef UINT_PTR SOCKET;
#endif
#ifdef __LINUX__
extern int FTPObjThread(void *obj);
#else

View File

@ -65,6 +65,7 @@
#ifdef WIN32
#include <windows.h>
#include <winsock.h>
#include <process.h>
typedef int socklen_t;
#endif

View File

@ -120,6 +120,7 @@
#ifdef WIN32
#include <windows.h>
#include <winsock.h>
#include <process.h>
#endif

View File

@ -22,7 +22,6 @@
#include "byteswap.h"
#if defined(WIN32)
#include <windows.h>
#include "ddraw.h"
#elif defined(__LINUX__)
#include "linux/linux_fix.h"
#include "lnxscreenmode.h"

View File

@ -87,14 +87,6 @@ void sound_render_end_frame() {
Geometry = NULL;
}
// places listener in world
void sound_render_listener_in_world(pos_state *listener_pos) {
ASSERT(Geometry);
// update listener
Int3();
}
// render one room's geometry
// dont render portal faces!
void sound_render_room_geometry(int iroom, int slot) {
@ -192,235 +184,3 @@ short *sound_render_audible_rooms(pos_state *listener_pos, float max_radius) {
return (short *)Sound_room_list;
}
/////////////////////////////////////////////////////////////////////////////
void start_sound_frame();
void end_sound_frame();
bool render_sound_objects_in_geometry();
bool render_sound_geometry_frame();
void play_3d_sound(const char *name, object *obj, float vol, int uid);
play_information sound_play_info[32];
static pos_state listener_pos_state;
/////////////////////////////////////////////////////////////////////////////
#if defined(WIN32)
#include <windows.h>
#endif
void aureal_test() {
#if defined(WIN32)
llsSystem *lls;
char old_mixer = Sound_system.GetSoundMixer();
bool quit = false, start_sounds = true;
int i, s;
angvec listener_ang;
matrix listener_orient, new_orient;
vector listener_pos;
vector listener_vel;
float frame_time = 0.1f;
const char *sound_names[] = {"Raindrop", "BreakingGlass", "Cheater!", NULL};
// initialize aureal and debug viewer
Sound_system.SetSoundMixer(SOUND_MIXER_AUREAL);
lls = Sound_system.m_ll_sound_ptr;
// listener_pos.position = &Viewer_object->pos;
// listener_pos.velocity = &Viewer_object->mtype.phys_info.velocity;
// listener_pos.orient = &Viewer_object->orient;
listener_pos = Viewer_object->pos;
listener_orient = Viewer_object->orient;
listener_vel = Viewer_object->mtype.phys_info.velocity;
listener_pos_state.position = &listener_pos;
listener_pos_state.velocity = &listener_vel;
listener_pos_state.orient = &listener_orient;
listener_pos_state.roomnum = Viewer_object->roomnum;
// use D3 geo
while (!quit) {
int key;
MSG msg;
matrix rotmat;
float frame_start_time;
frame_start_time = timer_GetTime();
while (1) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
exit(1);
}
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
ddio_Frame();
Sleep(50);
break;
}
}
start_sound_frame();
while ((key = ddio_KeyInKey()) != 0) {
if (key == KEY_ESC) {
lls->StopAllSounds();
quit = true;
} else if (key == KEY_2) {
mprintf((0, "aureal test stop sounds.\n"));
lls->StopAllSounds();
} else if (key == KEY_1) {
start_sounds = true;
}
}
listener_ang.p = 0;
listener_ang.b = 0;
listener_ang.h = 0;
listener_vel.z = 0;
if (KEY_STATE(KEY_LEFT)) {
listener_ang.h = -4096.0f * frame_time;
}
if (KEY_STATE(KEY_RIGHT)) {
listener_ang.h = 4096.0f * frame_time;
}
if (KEY_STATE(KEY_UP)) {
listener_ang.p = -4096.0f * frame_time;
}
if (KEY_STATE(KEY_DOWN)) {
listener_ang.p = 4096.0f * frame_time;
}
if (KEY_STATE(KEY_A)) {
listener_vel.z = 8.0f * frame_time;
}
if (KEY_STATE(KEY_Z)) {
listener_vel.z = -8.0f * frame_time;
}
vm_AnglesToMatrix(&rotmat, listener_ang.p, listener_ang.h, listener_ang.b);
new_orient = listener_orient * rotmat;
vm_Orthogonalize(&new_orient);
listener_orient = new_orient;
vm_TransposeMatrix(&new_orient);
listener_pos = listener_pos + (listener_vel * new_orient);
if (start_sounds) {
if (!ROOMNUM_OUTSIDE(listener_pos_state.roomnum)) {
int obji;
room *rp = &Rooms[listener_pos_state.roomnum];
mprintf((0, "aureal test start sounds.\n"));
s = 0, i = 0;
obji = rp->objects;
while (obji != -1 && i < 8) {
if (sound_names[s] && Objects[obji].type != OBJ_VIEWER && Objects[obji].type != OBJ_PLAYER) {
mprintf((0, "aureal test adding sound.\n"));
play_3d_sound(sound_names[s], &Objects[obji], 1.0f, i);
s++;
} else if (!sound_names[s]) {
s = 0;
}
obji = Objects[obji].next;
i++;
}
}
start_sounds = false;
}
end_sound_frame();
frame_time = timer_GetTime() - frame_start_time;
}
#ifndef RELEASE
// restore old mixer and ask user to terminate debug viewer before we do.
OutrageMessageBox("Please terminate debug viewer");
#endif
Sound_system.SetSoundMixer(old_mixer);
#endif // #ifdef WIN32
}
/////////////////////////////////////////////////////////////////////////////
// sequencing functions
void start_sound_frame() {
#if defined(WIN32)
// update lowlevel sound library
Sound_system.m_ll_sound_ptr->SoundStartFrame();
sound_render_start_frame();
// render sound geometry!
render_sound_geometry_frame();
#endif
}
void end_sound_frame() {
#if defined(WIN32)
sound_render_end_frame();
Sound_system.m_ll_sound_ptr->SoundEndFrame();
#endif
}
// render_sound_geometry_frame
// returns: false if sound system can't do this internally, or other error.
// in this case, the caller should emulate 3d sound.
bool render_sound_geometry_frame() {
#if defined(WIN32)
llsGeometry *geometry = Sound_system.m_ll_sound_ptr->GetGeometryInterface();
int iroom;
if (!render_sound_objects_in_geometry()) {
return false;
}
if (!geometry) { // we couldn't access a geometry interface
return false;
}
iroom = Viewer_object->roomnum;
sound_render_room_geometry(iroom, 0);
return true;
#else
return false;
#endif
}
bool render_sound_objects_in_geometry() {
#if defined(WIN32)
llsGeometry *geometry = Sound_system.m_ll_sound_ptr->GetGeometryInterface();
if (!geometry) { // we couldn't access a geometry interface
return false;
}
// update listener
sound_render_listener_in_world(&listener_pos_state);
return true;
#else
return false;
#endif
}
void play_3d_sound(const char *name, object *obj, float vol, int uid) {
llsSystem *lls = Sound_system.m_ll_sound_ptr;
int index = FindSoundName(name);
pos_state cur_pos;
if (!lls->CheckAndForceSoundDataAlloc(index)) {
mprintf((0, "failed to play 3d sound due to alloc error.\n"));
return;
}
cur_pos.position = &obj->pos;
cur_pos.orient = &obj->orient;
cur_pos.velocity = &obj->mtype.phys_info.velocity;
cur_pos.roomnum = obj->roomnum;
memset(&sound_play_info[uid], 0, sizeof(play_information));
sound_play_info[uid].samples_per_22khz_sample = 1.0;
sound_play_info[uid].sample_skip_interval = 0;
if (lls->PlaySound3d(&sound_play_info[uid], index, &cur_pos, vol, true) == -1) {
mprintf((0, "failed to play 3d sound.\n"));
}
}

View File

@ -1,4 +1,3 @@
set(HEADERS win32os.h)
set(CPPS
winapp.cpp
wincon.cpp
@ -7,6 +6,6 @@ set(CPPS
wintask.cpp
)
add_library(win32 STATIC ${HEADERS} ${CPPS})
add_library(win32 STATIC ${CPPS})
add_dependencies(win32 get_git_hash)
target_include_directories(win32 PRIVATE ${PROJECT_BINARY_DIR}/lib)

View File

@ -311,9 +311,6 @@
#include "Controller.h"
#include <windows.h>
#include <process.h>
#include <math.h>
#include "pserror.h"

View File

@ -1,34 +0,0 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Win32 OS Specific internal header to win32 library */
#ifndef WIN32OS_H
#define WIN32OS_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "gameos.h"
typedef struct win32oss_info {
HWND hwnd;
HINSTANCE hinst;
} win32oss_info;
#endif

View File

@ -152,15 +152,10 @@
#include "mono.h"
#include "networking.h"
#define WIN32_LEAN_AND_MEAN
#include <shellapi.h>
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
#include <stdlib.h>
#include "pserror.h"
#include "win\directx\ddraw.h"
#include "win\directx\dsound.h"
// taken from winuser.h
#ifndef WHEEL_DELTA

View File

@ -72,7 +72,6 @@
#include "AppConsole.h"
#include "TaskSystem.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string.h>
#include <process.h>

View File

@ -70,7 +70,6 @@
#include "AppDatabase.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <assert.h>