Fixed a code collision in a previous attempt at merging Windows and Mac codes, which would prevent the move_to_zero function to work with short types.

Most obvious effects were infinite bless, haste, poison, webs not cleaning, etc

Chokboyz

git-svn-id: http://openexile.googlecode.com/svn/trunk@151 4ebdad44-0ea0-11de-aab3-ff745001d230
This commit is contained in:
Chokboyz
2010-05-25 23:30:07 +00:00
parent b7f759ba0f
commit 4aef873372
4 changed files with 64 additions and 79 deletions

View File

@@ -2,6 +2,7 @@
#include "global.h"
#include <cmath>
#include "globvar.h"
#include "tools/mathutil.h"
RECT RECT16::rect32()
{

View File

@@ -446,25 +446,6 @@ void alter_rect(RECT *r) ;
void alter_rect(RECT16 *r) ;
Boolean sd_legit(short a, short b);
template <class T>
T minmax(T min, T max, T k)
{
return (k < min)? min : (k > max)? max : k;
};
template <class T>
T ex_abs(T value)
{
return (value < 0)? (-value) : value;
};
template <class T>
void move_to_zero(T & value)
{
if (value > 0) --value;
else if (value < 0) ++value;
};
typedef struct {
short queued_special;

View File

@@ -9,6 +9,8 @@
#include <cstdlib>
#include "mathutil.h"
//minmax, move_to_zero and ex_abs (return absolute value) are templates in the header file
short get_ran (short times,short min,short max){
long int store;
short i, to_ret = 0;
@@ -43,22 +45,6 @@ short min(short a,short b){
else return b;
}
short minmax(short min,short max,short k){
if (k < min)
return min;
if (k > max)
return max;
return k;
}
short move_to_zero(short val){
if (val < 0)
return val + 1;
if (val > 0)
return val - 1;
return val;
}
short gcd(short a, short b){ // Grabbed from Wikipedia and translated to C code
short t;
while(b != 0){

View File

@@ -22,6 +22,23 @@ extern short s_pow(short x,short y);
short s_sqrt(short val);
short max(short a,short b);
short min(short a,short b);
short minmax(short min,short max,short k);
short move_to_zero(short val);
short gcd(short a, short b);
template <class T>
void move_to_zero(T & value)
{
if (value > 0) --value;
else if (value < 0) ++value;
};
template <class T>
T minmax(T min, T max, T k)
{
return (k < min)? min : (k > max)? max : k;
};
template <class T>
T ex_abs(T value)
{
return (value < 0)? (-value) : value;
};