From: <rog...@us...> - 2015-01-26 19:46:41
|
Revision: 5089 http://sourceforge.net/p/desmume/code/5089 Author: rogerman Date: 2015-01-26 19:46:34 +0000 (Mon, 26 Jan 2015) Log Message: ----------- GFX3D: - Fix possible invalid memory access crashes when Y-sorting, most notably, in Super Mario 64 adventure mode. Using std::stable_sort() instead of std::sort() should have little to no performance impact since we're not sorting a lot of elements here. (Regression from r2436.) Revision Links: -------------- http://sourceforge.net/p/desmume/code/2436 Modified Paths: -------------- trunk/desmume/src/gfx3d.cpp Modified: trunk/desmume/src/gfx3d.cpp =================================================================== --- trunk/desmume/src/gfx3d.cpp 2015-01-26 05:22:43 UTC (rev 5088) +++ trunk/desmume/src/gfx3d.cpp 2015-01-26 19:46:34 UTC (rev 5089) @@ -2095,8 +2095,7 @@ //make sure we respect the game's ordering in cases of complete ties //this makes it a stable sort. //this must be a stable sort or else advance wars DOR will flicker in the main map mode - if (num1 < num2) return true; - else return false; + return (num1 < num2); } static void gfx3d_doFlush() @@ -2187,13 +2186,13 @@ //now we have to sort the opaque polys by y-value. //(test case: harvest moon island of happiness character cretor UI) //should this be done after clipping?? - std::sort(gfx3d.indexlist.list, gfx3d.indexlist.list + opaqueCount, gfx3d_ysort_compare); + std::stable_sort(gfx3d.indexlist.list, gfx3d.indexlist.list + opaqueCount, gfx3d_ysort_compare); if(!gfx3d.state.sortmode) { //if we are autosorting translucent polys, we need to do this also //TODO - this is unverified behavior. need a test case - std::sort(gfx3d.indexlist.list + opaqueCount, gfx3d.indexlist.list + polycount, gfx3d_ysort_compare); + std::stable_sort(gfx3d.indexlist.list + opaqueCount, gfx3d.indexlist.list + polycount, gfx3d_ysort_compare); } //switch to the new lists This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |