From 7faffdc674cb8b7fbff22bf254ec3805320ec5c4 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 24 Mar 2013 18:55:18 +0000 Subject: [PATCH] engine: return early with 0 from cansee() if either sector is >= MAXSECTORS. Previously, only the <0 condition was checked. However, the passed sectnums could be >= MAXSECTORS (at least in C-CON), for example when issuing 'canseespr' on a sprite not in the game world. git-svn-id: https://svn.eduke32.com/eduke32@3603 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 7792e4e00..e6f6f58ef 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -11165,8 +11165,10 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in int16_t pendingsectnum; vec3_t pendingvec; - // invalid sectnums can happen, for example if the player is using noclip - if (sect1 < 0 || sect2 < 0) + // Negative sectnums can happen, for example if the player is using noclip. + // MAXSECTORS can happen from C-CON, e.g. canseespr with a sprite not in + // the game world. + if ((unsigned)sect1 >= MAXSECTORS || (unsigned)sect2 >= MAXSECTORS) return 0; Bmemset(&pendingvec, 0, sizeof(vec3_t)); // compiler-happy