- Replaced all occurrences of FillCRect with the new tileImage, to get away from 'ppat' resources. - Fixed a minor error in the character editor where part of a text string was off the window. - With the prefix header gone, libticpp.dylib has been removed; TinyXML++ is now compiled right into the program. - The scenario editor splash screen is now loaded from a file. - The pc editor title has its transparency problem fixed. - Added an overload of tileImage that takes a RgnHandle instead of a Rect in order to replace the single occurrence of FillCRgn. - Removed an unused function in boe.graphics.cpp - Changed loading of patterns. Instead of loading each pattern individually from a resource, a single file containing all of them is loading. The arrays that formerly contained the actual patterns now contain the source rects of the patterns. - Fixed the cursor hotspots (the coordinates were reversed) - Removed the useless flip_pict that was written when I didn't know what I was doing. - Fixed error in tileImage in which vrep and hrep were switched. - Added code to tileImage to ensure that the pattern will line up with anything already onscreen, regardless of the rect to fill. - Two images were altered: pcedtitle.png to fix the transparenct problem, and pixpats.png to add one pattern that had been missed (and also rearrange the smaller patterns a little) git-svn-id: http://openexile.googlecode.com/svn/trunk@91 4ebdad44-0ea0-11de-aab3-ff745001d230
70 lines
1.1 KiB
C++
70 lines
1.1 KiB
C++
/*
|
|
* mathutil.cpp
|
|
* BoE
|
|
*
|
|
* Created by Celtic Minstrel on 16/04/09.
|
|
*
|
|
*/
|
|
|
|
#include <cstdlib>
|
|
#include "mathutil.h"
|
|
|
|
short get_ran (short times,short min,short max){
|
|
long int store;
|
|
short i, to_ret = 0;
|
|
|
|
if(max < min) max = min;
|
|
|
|
for (i = 1; i < times + 1; i++) {
|
|
store = rand();
|
|
to_ret += min + (store % (max - min + 1));//min + (((store + 32767) * (max - min + 1)) / 65536);
|
|
}
|
|
return to_ret;
|
|
}
|
|
|
|
short s_pow(short x,short y){
|
|
return (short) pow((double) x, (double) y);
|
|
}
|
|
|
|
short s_sqrt(short val)
|
|
{
|
|
return (short) sqrt((double)(val));
|
|
}
|
|
|
|
short max(short a,short b){
|
|
if (a > b)
|
|
return a;
|
|
else return b;
|
|
}
|
|
|
|
short min(short a,short b){
|
|
if (a < b)
|
|
return a;
|
|
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){
|
|
t = b;
|
|
b = a % b;
|
|
a = t;
|
|
}
|
|
return a;
|
|
} |