mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
engine.c: in calc_bufplc(), cope with negative lwall[] values.
This should fix the crash encountered here: http://forums.duke4.net/topic/1348-mapster32-problems-and-bugs/page__view__findpost__p__184069 a-c.c also gets a new switch macro, DEBUG_WITH_VALGRIND. git-svn-id: https://svn.eduke32.com/eduke32@4292 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
21a8788b6b
commit
546a112741
2 changed files with 22 additions and 2 deletions
|
@ -8,6 +8,15 @@
|
|||
|
||||
#include "a.h"
|
||||
|
||||
// For this, it's also sensible to uncomment DEBUG_ALLOCACHE_AS_MALLOC:
|
||||
//#define DEBUG_WITH_VALGRIND
|
||||
|
||||
#ifdef DEBUG_WITH_VALGRIND
|
||||
// For debugging with Valgrind + GDB, see
|
||||
// http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver
|
||||
# include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENGINE_USING_A_C
|
||||
|
||||
int32_t krecip(int32_t num); // from engine.c
|
||||
|
@ -122,9 +131,19 @@ static inline uint32_t ourmulscale32(uint32_t a, uint32_t b)
|
|||
static inline int32_t getpix(int32_t logy, const char *buf, uint32_t vplc)
|
||||
{
|
||||
if (logy != 0)
|
||||
{
|
||||
#ifdef DEBUG_WITH_VALGRIND
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(&buf[vplc>>logy], 1);
|
||||
#endif
|
||||
return buf[vplc>>logy];
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_WITH_VALGRIND
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(&buf[ourmulscale32(vplc,globaltilesizy)], 1);
|
||||
#endif
|
||||
return buf[ourmulscale32(vplc,globaltilesizy)];
|
||||
}
|
||||
}
|
||||
|
||||
void setupvlineasm(int32_t neglogy) { glogy = neglogy; }
|
||||
|
|
|
@ -2745,12 +2745,13 @@ static WSHELPER_DECL void tweak_tsizes(int32_t *tsizx, int32_t *tsizy)
|
|||
|
||||
static WSHELPER_DECL void calc_bufplc(intptr_t *bufplc, int32_t lw, int32_t tsizx, int32_t tsizy)
|
||||
{
|
||||
// CAUTION: lw can be negative!
|
||||
int32_t i = lw + globalxpanning;
|
||||
|
||||
if (i >= tsizx)
|
||||
// if (i >= tsizx)
|
||||
{
|
||||
if (tsizx < 0)
|
||||
i %= tsizx;
|
||||
i = (uint32_t)i % tsizx;
|
||||
else
|
||||
i &= tsizx;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue