diff --git a/source/sw/src/break.cpp b/source/sw/src/break.cpp index fafb75a4d..549de5706 100644 --- a/source/sw/src/break.cpp +++ b/source/sw/src/break.cpp @@ -432,26 +432,23 @@ BREAK_INFO SpriteBreakInfo[] = // SORT & SEARCH SUPPORT ////////////////////////////////////////////// -int CompareBreakInfo(BREAK_INFOp break_info1, BREAK_INFOp break_info2) +static int CompareBreakInfo(void const * a, void const * b) { + auto break_info1 = (BREAK_INFO const *)a; + auto break_info2 = (BREAK_INFO const *)b; + // will return a number less than 0 if break_info1 < break_info2 return break_info1->picnum - break_info2->picnum; } -int CompareSearchBreakInfo(short *picnum, BREAK_INFOp break_info) -{ - // will return a number less than 0 if picnum < break_info->picnum - return *picnum - break_info->picnum; -} - BREAK_INFOp FindWallBreakInfo(short picnum) { - return bsearch(&picnum, &WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), (int(*)(const void *,const void *))CompareSearchBreakInfo); + return (BREAK_INFOp)bsearch(&picnum, &WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), CompareBreakInfo); } BREAK_INFOp FindSpriteBreakInfo(short picnum) { - return bsearch(&picnum, &SpriteBreakInfo, SIZ(SpriteBreakInfo), sizeof(BREAK_INFO), (int(*)(const void *,const void *))CompareSearchBreakInfo); + return (BREAK_INFOp)bsearch(&picnum, &SpriteBreakInfo, SIZ(SpriteBreakInfo), sizeof(BREAK_INFO), CompareBreakInfo); } ////////////////////////////////////////////// @@ -460,8 +457,8 @@ BREAK_INFOp FindSpriteBreakInfo(short picnum) void SortBreakInfo(void) { - qsort(&SpriteBreakInfo, SIZ(SpriteBreakInfo), sizeof(BREAK_INFO), (int(*)(const void *,const void *))CompareBreakInfo); - qsort(&WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), (int(*)(const void *,const void *))CompareBreakInfo); + qsort(&SpriteBreakInfo, SIZ(SpriteBreakInfo), sizeof(BREAK_INFO), CompareBreakInfo); + qsort(&WallBreakInfo, SIZ(WallBreakInfo), sizeof(BREAK_INFO), CompareBreakInfo); } BREAK_INFOp SetupWallForBreak(WALLp wallp) diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 9463d75bf..30d9ce626 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1166,8 +1166,11 @@ GetDeltaAngle(short ang1, short ang2) TARGET_SORT TargetSort[MAX_TARGET_SORT]; unsigned TargetSortCount; -int CompareTarget(TARGET_SORTp tgt1, TARGET_SORTp tgt2) +static int CompareTarget(void const * a, void const * b) { + auto tgt1 = (TARGET_SORT const *)a; + auto tgt2 = (TARGET_SORT const *)b; + // will return a number less than 0 if tgt1 < tgt2 return tgt2->weight - tgt1->weight; } @@ -1294,7 +1297,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets) } if (TargetSortCount > 1) - qsort(&TargetSort,TargetSortCount,sizeof(TARGET_SORT),(int(*)(const void *,const void *))CompareTarget); + qsort(&TargetSort, TargetSortCount, sizeof(TARGET_SORT), CompareTarget); return TargetSort[0].sprite_num; }