mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
SW: Fix questionable function pointer typecasts
Patch from Striker. git-svn-id: https://svn.eduke32.com/eduke32@7502 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d842dc761d
commit
c456c414da
2 changed files with 13 additions and 13 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue