Skip to content

Commit

Permalink
Merge pull request #479 from DescentDevelopers/editor-fix-deprecation
Browse files Browse the repository at this point in the history
Fix deprecation warning about  /Zc:forScope-
  • Loading branch information
Lgt2x authored Aug 18, 2024
2 parents f97ab8a + 6f70379 commit 3cb1e89
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 115 deletions.
8 changes: 3 additions & 5 deletions editor/AmbientSoundPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ void CAmbientSoundPattern::OnASPNewElement() {
mem_free(asp->sounds);

asp->sounds = new_sounds;
asp->sounds[s] = new_element;
asp->sounds[asp->num_sounds++] = new_element;

asp->num_sounds++;

m_current_element = s;
m_current_element = asp->num_sounds;

UpdateDialog();
}
Expand Down Expand Up @@ -258,7 +256,7 @@ void CAmbientSoundPattern::OnASPDeleteElement() {
for (int s = 0; s < m_current_element; s++)
new_sounds[s] = asp->sounds[s];

for (; s < asp->num_sounds - 1; s++)
for (int s = m_current_element; s < asp->num_sounds - 1; s++)
new_sounds[s] = asp->sounds[s + 1];

mem_free(asp->sounds);
Expand Down
14 changes: 7 additions & 7 deletions editor/AnimStatesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,19 +608,19 @@ void CAnimStatesDialog::UpdateDialog() {
if (!m_setup_sound_dialogs) {
m_setup_sound_dialogs = true;

for (i = 0; i < max_states; i++) {
for (int i = 0; i < max_states; i++) {
SendDlgItemMessage(anim_sounds[i], CB_RESETCONTENT, 0, 0);
}
for (i = 0; i < MAX_SOUNDS; i++) {
if (Sounds[i].used) {
for (auto & Sound : Sounds) {
if (Sound.used) {
for (int j = 0; j < max_states; j++) {
SendDlgItemMessage(anim_sounds[j], CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name);
SendDlgItemMessage(anim_sounds[j], CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sound.name);
}
}
}
}

for (i = 0; i < max_states; i++) {
for (int i = 0; i < max_states; i++) {
if (m_anim[mc].elem[i].anim_sound_index >= 0 && m_anim[mc].elem[i].anim_sound_index < MAX_SOUNDS &&
Sounds[m_anim[mc].elem[i].anim_sound_index].used != 0)
SendDlgItemMessage(anim_sounds[i], CB_SELECTSTRING, 0,
Expand All @@ -630,14 +630,14 @@ void CAnimStatesDialog::UpdateDialog() {
}

SendDlgItemMessage(IDC_CURRENT_STATE_PULLDOWN, CB_RESETCONTENT, 0, 0);
for (i = 0; i < NUM_MOVEMENT_CLASSES; i++)
for (int i = 0; i < NUM_MOVEMENT_CLASSES; i++)
SendDlgItemMessage(IDC_CURRENT_STATE_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Movement_class_names[i]);

SendDlgItemMessage(IDC_CURRENT_STATE_PULLDOWN, CB_SELECTSTRING, 0,
(LPARAM)(LPCTSTR)Movement_class_names[m_current_state]);

SendDlgItemMessage(IDC_CURRENT_ANIMATION_PULLDOWN, CB_RESETCONTENT, 0, 0);
for (i = 0; i < NUM_ANIMS_PER_CLASS; i++)
for (int i = 0; i < NUM_ANIMS_PER_CLASS; i++)
SendDlgItemMessage(IDC_CURRENT_ANIMATION_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Anim_state_names[i]);

SendDlgItemMessage(IDC_CURRENT_ANIMATION_PULLDOWN, CB_SELECTSTRING, 0,
Expand Down
8 changes: 5 additions & 3 deletions editor/BriefEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ bool BEAllocEffect(int *ret_screen, int *ret_effect) {
int curr_effect = -1;
int node = Briefing_screens[curr_screen].root_effect;
tBriefScreen *bscr = &Briefing_screens[curr_screen];
for (int i = 0; i < MAX_EFFECTS_PER_SCREEN; i++) {
int i;
for (i = 0; i < MAX_EFFECTS_PER_SCREEN; i++) {
if (!bscr->effects[i].used) {
curr_effect = i;
break;
Expand Down Expand Up @@ -1119,7 +1120,8 @@ bool CBriefEdit::BriefEditAllocateEffect(int *ret_screen, int *ret_effect) {
int curr_effect = -1;
int node = Briefing_screens[curr_screen].root_effect;
tBriefScreen *bscr = &Briefing_screens[curr_screen];
for (int i = 0; i < MAX_EFFECTS_PER_SCREEN; i++) {
int i;
for (i = 0; i < MAX_EFFECTS_PER_SCREEN; i++) {
if (!bscr->effects[i].used) {
curr_effect = i;
break;
Expand Down Expand Up @@ -1989,7 +1991,7 @@ void CBriefEdit::ParseLayoutScreenFile(char *filename) {
}

// read bmp defs
for (j = 0; j < layouts[i].num_bmps; j++) {
for (int j = 0; j < layouts[i].num_bmps; j++) {
cf_ReadString(buffer, 512, file);

// now parse to pull out the individual values
Expand Down
44 changes: 37 additions & 7 deletions editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -560,22 +560,52 @@ set(SOURCE
editor.rc
../Descent3/sdlmain.cpp
)
set(CMAKE_MFC_FLAG 1)

# Editor only works in Windows, because of MFC and DirectX dependencies
set(PLATFORM_LIBS linux wsock32.lib winmm.lib dd_grwin32 win32 SDL2::SDL2)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB:LIBC")

add_executable(Descent3Editor WIN32 ${HEADERS} ${SOURCE})

add_executable(Descent3Editor WIN32 ${HEADERS} ${SOURCE})
target_include_directories(Descent3Editor PRIVATE ../lib ../ ../manage/ ${PROJECT_BINARY_DIR}/lib)

target_compile_definitions(Descent3Editor PUBLIC _AFXDLL EDITOR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} /Zc:forScope-")

target_link_libraries(Descent3Editor PRIVATE
2dlib AudioEncode bitmap cfile dd_video ddebug ddio libmve libacm
fix grtext manage mem misc model module stream_audio
music networking physics renderer rtperformance sndlib ui unzip vecmat md5
${PLATFORM_LIBS})
# Link libraries
target_link_libraries(Descent3Editor
2dlib
AudioEncode
bitmap
cfile

dd_video
ddio
ddebug
libmve
libacm
fix
grtext
manage
mem
misc
model
module

stream_audio
music
networking
physics
renderer
rtperformance
sndlib
ui
unzip
vecmat
md5
${PLATFORM_LIBS}
)

target_link_options(Descent3Editor PRIVATE $<$<PLATFORM_ID:Windows>:/DEBUG:FULL>)

add_dependencies(Descent3Editor get_git_hash)
Expand Down
48 changes: 23 additions & 25 deletions editor/Erooms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ void GetUVLForRoomPoint(int roomnum, int facenum, int vertnum, roomUVL *uvl) {

// find the center point of this face
vm_MakeZero(&avg_vert);
for (int i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++)
int i;
for (i = 0; i < Rooms[roomnum].faces[facenum].num_verts; i++)
avg_vert += Rooms[roomnum].verts[Rooms[roomnum].faces[facenum].face_verts[i]];

avg_vert /= i;
Expand Down Expand Up @@ -766,11 +767,9 @@ void AssignDefaultUVsToRoomFace(room *rp, int facenum) {
// Searches thru all rooms for a specific name, returns -1 if not found
// or index of room with name
int FindRoomName(char *name) {
int i;

ASSERT(name != NULL);

for (i = FIRST_PALETTE_ROOM; i < FIRST_PALETTE_ROOM + MAX_PALETTE_ROOMS; i++)
for (int i = FIRST_PALETTE_ROOM; i < FIRST_PALETTE_ROOM + MAX_PALETTE_ROOMS; i++)
if (Rooms[i].used && Rooms[i].name && !stricmp(name, Rooms[i].name))
return i;

Expand Down Expand Up @@ -835,7 +834,7 @@ void SaveRoom(int n, char *filename) {
cfseek(outfile, savepos, SEEK_SET);

// figure out correct texture ordering
for (i = 0; i < Rooms[n].num_faces; i++) {
for (int i = 0; i < Rooms[n].num_faces; i++) {
int16_t index = Rooms[n].faces[i].tmap;

for (found_it = 0, t = 0; t < highest_index; t++) {
Expand All @@ -861,7 +860,7 @@ void SaveRoom(int n, char *filename) {
// Write out how many different textures there are and then write their names
cf_WriteInt(outfile, highest_index);

for (i = 0; i < highest_index; i++) {
for (int i = 0; i < highest_index; i++) {
int index = Room_to_texture[i];
cf_WriteString(outfile, GameTextures[index].used ? GameTextures[index].name : "");
}
Expand All @@ -876,7 +875,7 @@ void SaveRoom(int n, char *filename) {
facesize = cftell(outfile);
cf_WriteInt(outfile, -1);

for (i = 0; i < Rooms[n].num_faces; i++) {
for (int i = 0; i < Rooms[n].num_faces; i++) {
cf_WriteByte(outfile, Rooms[n].faces[i].light_multiple);
cf_WriteInt(outfile, Rooms[n].faces[i].num_verts);

Expand Down Expand Up @@ -1073,18 +1072,16 @@ int AllocLoadRoom(char *filename, bool bCenter, bool palette_room) {

// Gets next palette room (from n) that has actually been alloced
int GetNextRoom(int n) {
int i;

ASSERT((n == -1) || ((n >= FIRST_PALETTE_ROOM) && n < FIRST_PALETTE_ROOM + MAX_PALETTE_ROOMS));

if (n == -1) // start at beginning
n = FIRST_PALETTE_ROOM - 1;

for (i = n + 1; i < FIRST_PALETTE_ROOM + MAX_PALETTE_ROOMS; i++)
for (int i = n + 1; i < FIRST_PALETTE_ROOM + MAX_PALETTE_ROOMS; i++)
if (Rooms[i].used)
return i;

for (i = FIRST_PALETTE_ROOM; i <= n; i++)
for (int i = FIRST_PALETTE_ROOM; i <= n; i++)
if (Rooms[i].used)
return i;

Expand Down Expand Up @@ -1206,7 +1203,7 @@ bool FaceIsPlanar(int nv, int16_t *face_verts, vector *normal, vector *verts) {

// Look for points too far from the average
float d;
for (v = 0; v < nv; v++) {
for (int v = 0; v < nv; v++) {
d = verts[face_verts[v]] * *normal;
if (fabs(d - average_d) > POINT_TO_PLANE_EPSILON)
return 0;
Expand Down Expand Up @@ -1421,16 +1418,14 @@ int RoomAddVertices(room *rp, int num_new_verts) {
// num_new_faces - how many faces are being added to the room
// Returns: the number of the first new face
int RoomAddFaces(room *rp, int num_new_faces) {
int i;

if (num_new_faces == 0)
return 0;

face *newfaces = (face *)mem_malloc((rp->num_faces + num_new_faces) * sizeof(*newfaces));

ASSERT(newfaces != NULL);

for (i = 0; i < rp->num_faces; i++)
for (int i = 0; i < rp->num_faces; i++)
newfaces[i] = rp->faces[i];

mem_free(rp->faces);
Expand All @@ -1439,7 +1434,7 @@ int RoomAddFaces(room *rp, int num_new_faces) {
rp->num_faces += num_new_faces;

if (rp->num_bbf_regions) {
for (i = 0; i < rp->num_bbf_regions; i++) {
for (int i = 0; i < rp->num_bbf_regions; i++) {
mem_free(rp->bbf_list[i]);
}
mem_free(rp->bbf_list);
Expand Down Expand Up @@ -1819,6 +1814,7 @@ void DeleteRoomPortal(room *rp, int portalnum) {
}

// Copy portals over
int p;
for (p = 0; p < portalnum; p++)
newportals[p] = rp->portals[p];
for (p++; p < rp->num_portals; p++)
Expand Down Expand Up @@ -1954,7 +1950,7 @@ void CopyRoom(room *destp, room *srcp) {
}

// Copy over the verts
for (i = 0; i < destp->num_verts; i++)
for (int i = 0; i < destp->num_verts; i++)
destp->verts[i] = srcp->verts[i];

// Copy doorway info
Expand All @@ -1977,14 +1973,13 @@ void CopyRoom(room *destp, room *srcp) {
// Initializes the flags
int AddPortal(room *rp) {
portal *newlist;
int i;

newlist = (portal *)mem_malloc(sizeof(*newlist) * (rp->num_portals + 1));

// Copy from old list to new list, and free old list
if (rp->num_portals) {

for (i = 0; i < rp->num_portals; i++)
for (int i = 0; i < rp->num_portals; i++)
newlist[i] = rp->portals[i];

mem_free(rp->portals);
Expand Down Expand Up @@ -2266,7 +2261,8 @@ int CheckForDuplicateFace(room *rp, int facenum) {
if (fp0->num_verts == fp1->num_verts)
for (int v = 0; v < fp1->num_verts; v++) // look for a shared vert
if (fp1->face_verts[v] == fp0->face_verts[0]) {
for (int t = 0; t < fp0->num_verts; t++)
int t;
for (t = 0; t < fp0->num_verts; t++)
if (fp0->face_verts[t] != fp1->face_verts[(v + t) % fp1->num_verts])
break;
if (t == fp0->num_verts) {
Expand Down Expand Up @@ -2552,7 +2548,7 @@ void CountUniqueTextures() {

// Now count totals
int total = 0, total_with_lights = 0;
for (i = 0; i < MAX_TEXTURES; i++) {
for (int i = 0; i < MAX_TEXTURES; i++) {
if (texture_tracking[i]) {
if (!(GameTextures[i].flags & TF_LIGHT)) {
total++;
Expand All @@ -2568,15 +2564,15 @@ void CountUniqueTextures() {
if (total > 60)
CheckError("ERROR: YOU HAVE MORE THAT 60 128x128 TEXTURES...YOU *MUST* FIX THIS!\n");

for (i = 0; i < MAX_TEXTURES; i++) {
for (int i = 0; i < MAX_TEXTURES; i++) {
if (texture_tracking[i] && !(GameTextures[i].flags & TF_LIGHT)) {
CheckError("%d : %s %s bmp=%s\n", texture_tracking[i], GameTextures[i].name,
(GameTextures[i].flags & TF_ANIMATED) ? "(Animated)" : "",
(GameTextures[i].flags & TF_ANIMATED) ? "" : GameBitmaps[GameTextures[i].bm_handle].name);
}
}

for (i = 0; i < MAX_TEXTURES; i++) {
for (int i = 0; i < MAX_TEXTURES; i++) {
if (texture_tracking[i] && (GameTextures[i].flags & TF_LIGHT)) {
CheckError("%d : %s %s %s bmp=%s\n", texture_tracking[i], GameTextures[i].name,
(GameTextures[i].flags & TF_ANIMATED) ? "(Animated)" : "",
Expand Down Expand Up @@ -2916,7 +2912,9 @@ int RemoveDuplicateFacePoints(room *rp) {
int new_verts[MAX_VERTS_PER_FACE];
roomUVL new_uvls[MAX_VERTS_PER_FACE];

for (int t = 0; t < v; t++) {
int t;

for (t = 0; t < v; t++) {
new_verts[t] = fp->face_verts[t];
new_uvls[t] = fp->face_uvls[t];
}
Expand Down Expand Up @@ -2991,7 +2989,7 @@ void FixDegenerateFaces() {
tverts[i] = fp->face_verts[(v + 2 + i) % fp->num_verts];
tuvls[i] = fp->face_uvls[(v + 2 + i) % fp->num_verts];
}
for (i = 0; i < fp->num_verts - 2; i++) {
for (int i = 0; i < fp->num_verts - 2; i++) {
fp->face_verts[i] = tverts[i];
fp->face_uvls[i] = tuvls[i];
}
Expand Down
2 changes: 1 addition & 1 deletion editor/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ group *CopyGroup(int nrooms, int *roomnums, int attachroom, int attachface) {
// Get memory for triggers
g->triggers = (trigger *)mem_malloc(sizeof(*g->triggers) * n_triggers);

for (t = 0; t < Num_triggers; t++)
for (int t = 0; t < Num_triggers; t++)
if (room_xlate[Triggers[t].roomnum] != -1) {
g->triggers[trignum] = Triggers[t];
g->triggers[trignum].roomnum = room_xlate[Triggers[t].roomnum];
Expand Down
3 changes: 2 additions & 1 deletion editor/HFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ char *IntSpacing(int i) {

i = abs(i);

for (int n = 1; i >= 10; n++)
int n;
for (n = 1; i >= 10; n++)
i /= 10;

ASSERT(n <= 20);
Expand Down
Loading

0 comments on commit 3cb1e89

Please sign in to comment.