wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src display.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src display.cpp
Date: Thu, 07 Oct 2004 15:02:22 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/10/07 18:55:33

Modified files:
        src            : display.cpp 

Log message:
        Let's avoid calling a pure function 7 times in a row

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.cpp.diff?tr1=1.267&tr2=1.268&r1=text&r2=text

Patches:
Index: wesnoth/src/display.cpp
diff -u wesnoth/src/display.cpp:1.267 wesnoth/src/display.cpp:1.268
--- wesnoth/src/display.cpp:1.267       Thu Oct  7 18:42:59 2004
+++ wesnoth/src/display.cpp     Thu Oct  7 18:55:33 2004
@@ -1,4 +1,4 @@
-/* $Id: display.cpp,v 1.267 2004/10/07 18:42:59 silene Exp $ */
+/* $Id: display.cpp,v 1.268 2004/10/07 18:55:33 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -244,8 +244,9 @@
 
 gamemap::location display::pixel_position_to_hex(int x, int y)
 {
-       const int tesselation_x_size = hex_size() * 3 / 2;
-       const int tesselation_y_size = hex_size();
+       const int s = hex_size();
+       const int tesselation_x_size = s * 3 / 2;
+       const int tesselation_y_size = s;
        const int x_base = x / tesselation_x_size * 2;
        const int x_mod = x % tesselation_x_size;
        const int y_base = y / tesselation_y_size;
@@ -255,10 +256,10 @@
        int y_modifier;
        
        if (y_mod < tesselation_y_size / 2) {
-               if ((x_mod * 2 + y_mod) < (hex_size() / 2)) {
+               if ((x_mod * 2 + y_mod) < (s / 2)) {
                        x_modifier = -1;
                        y_modifier = -1;
-               } else if ((x_mod * 2 - y_mod) < (hex_size() * 3 / 2)) {
+               } else if ((x_mod * 2 - y_mod) < (s * 3 / 2)) {
                        x_modifier = 0;
                        y_modifier = 0;
                } else {
@@ -267,10 +268,10 @@
                }
                
        } else {
-               if ((x_mod * 2 - (y_mod - hex_size() / 2)) < 0) {
+               if ((x_mod * 2 - (y_mod - s / 2)) < 0) {
                        x_modifier = -1;
                        y_modifier = 0;
-               } else if ((x_mod * 2 + (y_mod - hex_size() / 2)) < hex_size() 
* 2) {
+               } else if ((x_mod * 2 + (y_mod - s / 2)) < s * 2) {
                        x_modifier = 0;
                        y_modifier = 0;
                } else {
@@ -279,8 +280,7 @@
                }
        }
 
-       return gamemap::location(x_base + x_modifier,
-               y_base + y_modifier);
+       return gamemap::location(x_base + x_modifier, y_base + y_modifier);
 }
 
 int display::get_location_x(const gamemap::location& loc) const




reply via email to

[Prev in Thread] Current Thread [Next in Thread]