From 21deb8709d46ee1563e8e7f6aa7eb310ec7ae8c3 Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Tue, 26 Feb 2013 18:47:14 +0000
Subject: [PATCH] [Change] Optimized getSpriteFromDir somewhat.

---
 src/opengl.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/opengl.c b/src/opengl.c
index 7936fc2..d5a9d26 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -325,13 +325,17 @@ int gl_isTrans(const glTexture* t, const int x, const int y) {
 
 // Set x and y to be the appropriate sprite for glTexture using dir.
 void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir) {
-  int s = (int)(dir / (2.0*M_PI / (t->sy*t->sx)));
+	int s, sx, sy;
+
+  s = (int)(dir / (2.0*M_PI / (t->sy*t->sx)));
+	sx = t->sx;
+	sy = t->sy;
 
   // Make sure the sprite is "in range".
-  if(s > (int)(t->sy*t->sx)-1) s = s % (int)(t->sy*t->sx);
+	if(s > (sy*sx-1)) s = s % (sy*sx);
 
-  *x = s % (int)t->sx;
-  *y = s / (int)t->sy;
+  *x = s % sx;
+  *y = s / sy;
 }
 
 // ================