mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-17 14:28:30 +01:00
Fix a metric ton of MSVC warnings
This commit is contained in:
parent
413c18950d
commit
4b7e85c2fb
30
src/Misc.cpp
30
src/Misc.cpp
@ -9,34 +9,6 @@
|
||||
|
||||
#include "common/tpt-minmax.h"
|
||||
|
||||
//Signum function
|
||||
int isign(float i) //TODO: INline or macro
|
||||
{
|
||||
if (i<0)
|
||||
return -1;
|
||||
if (i>0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned clamp_flt(float f, float min, float max) //TODO: Also inline/macro
|
||||
{
|
||||
if (f<min)
|
||||
return 0;
|
||||
if (f>max)
|
||||
return 255;
|
||||
return (int)(255.0f*(f-min)/(max-min));
|
||||
}
|
||||
|
||||
float restrict_flt(float f, float min, float max) //TODO Inline or macro or something
|
||||
{
|
||||
if (f<min)
|
||||
return min;
|
||||
if (f>max)
|
||||
return max;
|
||||
return f;
|
||||
}
|
||||
|
||||
const static char hex[] = "0123456789ABCDEF";
|
||||
void strcaturl(char *dst, char *src)
|
||||
{
|
||||
@ -227,7 +199,7 @@ void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v)//convert 0-255 RGB value
|
||||
else
|
||||
{
|
||||
c = (rr==a) ? gg-bb : ((bb==a) ? rr-gg : bb-rr);
|
||||
d = (rr==a) ? 3 : ((bb==a) ? 1 : 5);
|
||||
d = (rr==a) ? 3.f : ((bb==a) ? 1.f : 5.f);
|
||||
*h = (int)(60.0*(d - c/(x - a)));
|
||||
*s = (int)(255.0*((x - a)/x));
|
||||
*v = (int)(255.0*x);
|
||||
|
37
src/Misc.h
37
src/Misc.h
@ -12,12 +12,43 @@ template <typename T> inline T LinearInterpolate(T val1, T val2, T lowerCoord, T
|
||||
return (((val2 - val1) / (upperCoord - lowerCoord)) * (coord - lowerCoord)) + val1;
|
||||
}
|
||||
|
||||
|
||||
//Signum function
|
||||
int isign(float i);
|
||||
inline int isign(int i)
|
||||
{
|
||||
if (i<0)
|
||||
return -1;
|
||||
if (i>0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned clamp_flt(float f, float min, float max);
|
||||
inline int isign(float i)
|
||||
{
|
||||
if (i<0)
|
||||
return -1;
|
||||
if (i>0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float restrict_flt(float f, float min, float max);
|
||||
inline unsigned clamp_flt(float f, float min, float max)
|
||||
{
|
||||
if (f<min)
|
||||
return 0;
|
||||
if (f>max)
|
||||
return 255;
|
||||
return (int)(255.0f*(f-min)/(max-min));
|
||||
}
|
||||
|
||||
inline float restrict_flt(float f, float min, float max)
|
||||
{
|
||||
if (f<min)
|
||||
return min;
|
||||
if (f>max)
|
||||
return max;
|
||||
return f;
|
||||
}
|
||||
|
||||
void save_presets(int do_update);
|
||||
|
||||
|
@ -81,7 +81,7 @@ void DoRestart()
|
||||
if (exename.length())
|
||||
{
|
||||
#ifdef WIN
|
||||
int ret = (int)ShellExecute(NULL, NULL, exename.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||
int ret = int(INT_PTR(ShellExecute(NULL, NULL, exename.c_str(), NULL, NULL, SW_SHOWNORMAL)));
|
||||
if (ret <= 32)
|
||||
{
|
||||
fprintf(stderr, "cannot restart: ShellExecute(...) failed: code %i\n", ret);
|
||||
@ -109,7 +109,7 @@ void DoRestart()
|
||||
void OpenURI(ByteString uri)
|
||||
{
|
||||
#if defined(WIN)
|
||||
if ((int)ShellExecute(NULL, NULL, uri.c_str(), NULL, NULL, SW_SHOWNORMAL) <= 32)
|
||||
if (int(INT_PTR(ShellExecute(NULL, NULL, uri.c_str(), NULL, NULL, SW_SHOWNORMAL))) <= 32)
|
||||
{
|
||||
fprintf(stderr, "cannot open URI: ShellExecute(...) failed\n");
|
||||
}
|
||||
|
@ -390,12 +390,12 @@ void EngineProcess()
|
||||
|
||||
int frameTime = SDL_GetTicks() - frameStart;
|
||||
frameTimeAvg = frameTimeAvg * 0.8 + frameTime * 0.2;
|
||||
int fpsLimit = ui::Engine::Ref().FpsLimit;
|
||||
float fpsLimit = ui::Engine::Ref().FpsLimit;
|
||||
if(fpsLimit > 2)
|
||||
{
|
||||
double offset = 1000.0 / fpsLimit - frameTimeAvg;
|
||||
if(offset > 0)
|
||||
SDL_Delay(offset + 0.5);
|
||||
SDL_Delay(Uint32(offset + 0.5));
|
||||
}
|
||||
int correctedFrameTime = SDL_GetTicks() - frameStart;
|
||||
correctedFrameTimeAvg = correctedFrameTimeAvg * 0.95 + correctedFrameTime * 0.05;
|
||||
@ -464,7 +464,8 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("path to font.cpp not supplied");
|
||||
std::cerr << "path to font.cpp not supplied" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
EngineProcess();
|
||||
|
@ -575,12 +575,12 @@ void EngineProcess()
|
||||
|
||||
int frameTime = SDL_GetTicks() - frameStart;
|
||||
frameTimeAvg = frameTimeAvg * 0.8 + frameTime * 0.2;
|
||||
int fpsLimit = ui::Engine::Ref().FpsLimit;
|
||||
float fpsLimit = ui::Engine::Ref().FpsLimit;
|
||||
if(fpsLimit > 2)
|
||||
{
|
||||
double offset = 1000.0 / fpsLimit - frameTimeAvg;
|
||||
if(offset > 0)
|
||||
SDL_Delay(offset + 0.5);
|
||||
SDL_Delay(Uint32(offset + 0.5));
|
||||
}
|
||||
int correctedFrameTime = SDL_GetTicks() - frameStart;
|
||||
correctedFrameTimeAvg = correctedFrameTimeAvg * 0.95 + correctedFrameTime * 0.05;
|
||||
@ -758,12 +758,7 @@ int main(int argc, char * argv[])
|
||||
FILE *new_stderr = freopen("stderr.log", "w", stderr);
|
||||
if (!new_stdout || !new_stderr)
|
||||
{
|
||||
// no point in printing an error to stdout/stderr since the user probably
|
||||
// requests those streams be redirected because they can't see them
|
||||
// otherwise. so just throw an exception instead anf hope that the OS
|
||||
// and the standard library is smart enough to display the error message
|
||||
// in some useful manner.
|
||||
throw std::runtime_error("cannot honour request to redirect standard streams to log files");
|
||||
exit(42);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ int bson_iterator_int( const bson_iterator *i ) {
|
||||
case BSON_LONG:
|
||||
return bson_iterator_long_raw( i );
|
||||
case BSON_DOUBLE:
|
||||
return bson_iterator_double_raw( i );
|
||||
return int(bson_iterator_double_raw( i ));
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -453,7 +453,7 @@ double bson_iterator_double( const bson_iterator *i ) {
|
||||
case BSON_INT:
|
||||
return bson_iterator_int_raw( i );
|
||||
case BSON_LONG:
|
||||
return bson_iterator_long_raw( i );
|
||||
return double(bson_iterator_long_raw( i ));
|
||||
case BSON_DOUBLE:
|
||||
return bson_iterator_double_raw( i );
|
||||
default:
|
||||
@ -468,7 +468,7 @@ int64_t bson_iterator_long( const bson_iterator *i ) {
|
||||
case BSON_LONG:
|
||||
return bson_iterator_long_raw( i );
|
||||
case BSON_DOUBLE:
|
||||
return bson_iterator_double_raw( i );
|
||||
return int64_t(bson_iterator_double_raw( i ));
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -625,7 +625,7 @@ int bson_ensure_space( bson *b, const int bytesNeeded ) {
|
||||
if ( pos + bytesNeeded <= b->dataSize )
|
||||
return BSON_OK;
|
||||
|
||||
new_size = 1.5 * ( b->dataSize + bytesNeeded );
|
||||
new_size = int(1.5 * ( b->dataSize + bytesNeeded ));
|
||||
|
||||
if( new_size < b->dataSize ) {
|
||||
if( ( b->dataSize + bytesNeeded ) < INT_MAX )
|
||||
|
@ -286,14 +286,14 @@ vector2d GameSave::Translate(vector2d translate)
|
||||
{
|
||||
if (Collapsed())
|
||||
Expand();
|
||||
int nx, ny;
|
||||
float nx, ny;
|
||||
vector2d pos;
|
||||
vector2d translateReal = translate;
|
||||
float minx = 0, miny = 0, maxx = 0, maxy = 0;
|
||||
// determine minimum and maximum position of all particles / signs
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
{
|
||||
pos = v2d_new(signs[i].x, signs[i].y);
|
||||
pos = v2d_new(float(signs[i].x), float(signs[i].y));
|
||||
pos = v2d_add(pos,translate);
|
||||
nx = floor(pos.x+0.5f);
|
||||
ny = floor(pos.y+0.5f);
|
||||
@ -329,13 +329,13 @@ vector2d GameSave::Translate(vector2d translate)
|
||||
);
|
||||
int blockBoundsX = int(maxx / CELL) + 1, blockBoundsY = int(maxy / CELL) + 1;
|
||||
vector2d frontCorrection = v2d_new(
|
||||
(blockBoundsX > blockWidth) ? (blockBoundsX - blockWidth) : 0,
|
||||
(blockBoundsY > blockHeight) ? (blockBoundsY - blockHeight) : 0
|
||||
float((blockBoundsX > blockWidth) ? (blockBoundsX - blockWidth) : 0),
|
||||
float((blockBoundsY > blockHeight) ? (blockBoundsY - blockHeight) : 0)
|
||||
);
|
||||
|
||||
// get new width based on corrections
|
||||
int newWidth = (blockWidth + backCorrection.x + frontCorrection.x) * CELL;
|
||||
int newHeight = (blockHeight + backCorrection.y + frontCorrection.y) * CELL;
|
||||
auto newWidth = int((blockWidth + backCorrection.x + frontCorrection.x) * CELL);
|
||||
auto newHeight = int((blockHeight + backCorrection.y + frontCorrection.y) * CELL);
|
||||
if (newWidth > XRES)
|
||||
frontCorrection.x = backCorrection.x = 0;
|
||||
if (newHeight > YRES)
|
||||
@ -344,8 +344,8 @@ vector2d GameSave::Translate(vector2d translate)
|
||||
// call Transform to do the transformation we wanted when calling this function
|
||||
translate = v2d_add(translate, v2d_multiply_float(backCorrection, CELL));
|
||||
Transform(m2d_identity, translate, translateReal,
|
||||
(blockWidth + backCorrection.x + frontCorrection.x) * CELL,
|
||||
(blockHeight + backCorrection.y + frontCorrection.y) * CELL
|
||||
int((blockWidth + backCorrection.x + frontCorrection.x) * CELL),
|
||||
int((blockHeight + backCorrection.y + frontCorrection.y) * CELL)
|
||||
);
|
||||
|
||||
// return how much we corrected. This is used to offset the position of the current stamp
|
||||
@ -364,9 +364,9 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
|
||||
vector2d translateReal = translate;
|
||||
// undo any translation caused by rotation
|
||||
cornerso[0] = v2d_new(0,0);
|
||||
cornerso[1] = v2d_new(width-1,0);
|
||||
cornerso[2] = v2d_new(0,height-1);
|
||||
cornerso[3] = v2d_new(width-1,height-1);
|
||||
cornerso[1] = v2d_new(float(width-1),0);
|
||||
cornerso[2] = v2d_new(0,float(height-1));
|
||||
cornerso[3] = v2d_new(float(width-1),float(height-1));
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
tmp = m2d_multiply_v2d(transform,cornerso[i]);
|
||||
@ -379,8 +379,8 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
|
||||
// casting as int doesn't quite do what we want with negative numbers, so use floor()
|
||||
tmp = v2d_new(floor(ctl.x+0.5f),floor(ctl.y+0.5f));
|
||||
translate = v2d_sub(translate,tmp);
|
||||
newWidth = floor(cbr.x+0.5f)-floor(ctl.x+0.5f)+1;
|
||||
newHeight = floor(cbr.y+0.5f)-floor(ctl.y+0.5f)+1;
|
||||
newWidth = int(floor(cbr.x+0.5f))-int(floor(ctl.x+0.5f))+1;
|
||||
newHeight = int(floor(cbr.y+0.5f))-int(floor(ctl.y+0.5f))+1;
|
||||
Transform(transform, translate, translateReal, newWidth, newHeight);
|
||||
}
|
||||
|
||||
@ -416,10 +416,10 @@ void GameSave::Transform(matrix2d transform, vector2d translate, vector2d transl
|
||||
// rotate and translate signs, parts, walls
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
{
|
||||
pos = v2d_new(signs[i].x, signs[i].y);
|
||||
pos = v2d_new(float(signs[i].x), float(signs[i].y));
|
||||
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
|
||||
nx = floor(pos.x+0.5f);
|
||||
ny = floor(pos.y+0.5f);
|
||||
nx = int(floor(pos.x+0.5f));
|
||||
ny = int(floor(pos.y+0.5f));
|
||||
if (nx<0 || nx>=newWidth || ny<0 || ny>=newHeight)
|
||||
{
|
||||
signs[i].text[0] = 0;
|
||||
@ -433,15 +433,15 @@ void GameSave::Transform(matrix2d transform, vector2d translate, vector2d transl
|
||||
if (!particles[i].type) continue;
|
||||
pos = v2d_new(particles[i].x, particles[i].y);
|
||||
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
|
||||
nx = floor(pos.x+0.5f);
|
||||
ny = floor(pos.y+0.5f);
|
||||
nx = int(floor(pos.x+0.5f));
|
||||
ny = int(floor(pos.y+0.5f));
|
||||
if (nx<0 || nx>=newWidth || ny<0 || ny>=newHeight)
|
||||
{
|
||||
particles[i].type = PT_NONE;
|
||||
continue;
|
||||
}
|
||||
particles[i].x = nx;
|
||||
particles[i].y = ny;
|
||||
particles[i].x = float(nx);
|
||||
particles[i].y = float(ny);
|
||||
vel = v2d_new(particles[i].vx, particles[i].vy);
|
||||
vel = m2d_multiply_v2d(transform, vel);
|
||||
particles[i].vx = vel.x;
|
||||
@ -473,8 +473,8 @@ void GameSave::Transform(matrix2d transform, vector2d translate, vector2d transl
|
||||
{
|
||||
pos = v2d_new(x*CELL+CELL*0.4f+translateX, y*CELL+CELL*0.4f+translateY);
|
||||
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
|
||||
nx = pos.x/CELL;
|
||||
ny = pos.y/CELL;
|
||||
nx = int(pos.x/CELL);
|
||||
ny = int(pos.y/CELL);
|
||||
if (pos.x<0 || nx>=newBlockWidth || pos.y<0 || ny>=newBlockHeight)
|
||||
continue;
|
||||
if (blockMap[y][x])
|
||||
@ -996,7 +996,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
{
|
||||
tempTemp = ambientData[i++];
|
||||
tempTemp |= (((unsigned)ambientData[i++]) << 8);
|
||||
ambientHeat[blockY+y][blockX+x] = tempTemp;
|
||||
ambientHeat[blockY+y][blockX+x] = float(tempTemp);
|
||||
}
|
||||
}
|
||||
hasAmbientHeat = true;
|
||||
@ -1046,8 +1046,8 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
|
||||
//Required fields
|
||||
particles[newIndex].type = partsData[i];
|
||||
particles[newIndex].x = x;
|
||||
particles[newIndex].y = y;
|
||||
particles[newIndex].x = float(x);
|
||||
particles[newIndex].y = float(y);
|
||||
i+=3;
|
||||
|
||||
// Read type (2nd byte)
|
||||
@ -1060,7 +1060,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
//Full 16bit int
|
||||
tempTemp = partsData[i++];
|
||||
tempTemp |= (((unsigned)partsData[i++]) << 8);
|
||||
particles[newIndex].temp = tempTemp;
|
||||
particles[newIndex].temp = float(tempTemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1220,7 +1220,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
case PT_FIRW:
|
||||
if (particles[newIndex].tmp>=2 && savedVersion < 81)
|
||||
{
|
||||
int caddress = restrict_flt(restrict_flt((float)(particles[newIndex].tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
|
||||
auto caddress = int(restrict_flt(float(particles[newIndex].tmp-4), 0.0f, 199.0f)) * 3;
|
||||
particles[newIndex].type = PT_EMBR;
|
||||
particles[newIndex].tmp = 1;
|
||||
particles[newIndex].ctype = (((firw_data[caddress]))<<16) | (((firw_data[caddress+1]))<<8) | ((firw_data[caddress+2]));
|
||||
@ -1230,7 +1230,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
if (savedVersion < 87 && particles[newIndex].ctype)
|
||||
particles[newIndex].life = 1;
|
||||
if (savedVersion < 91)
|
||||
particles[newIndex].temp = 283.15;
|
||||
particles[newIndex].temp = 283.15f;
|
||||
break;
|
||||
case PT_FILT:
|
||||
if (savedVersion < 89)
|
||||
@ -1799,13 +1799,13 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
|
||||
if (particles[i-1].type==PT_PUMP) {
|
||||
particles[i-1].temp = ttv + 0.15;//fix PUMP saved at 0, so that it loads at 0.
|
||||
} else {
|
||||
particles[i-1].temp = ttv;
|
||||
particles[i-1].temp = float(ttv);
|
||||
}
|
||||
} else {
|
||||
particles[i-1].temp = (data[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP;
|
||||
particles[i-1].temp = float((data[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP);
|
||||
}
|
||||
} else {
|
||||
particles[i-1].temp = ((data[p++]*((O_MAX_TEMP+(-O_MIN_TEMP))/255))+O_MIN_TEMP)+273;
|
||||
particles[i-1].temp = float(((data[p++]*((O_MAX_TEMP+(-O_MIN_TEMP))/255))+O_MIN_TEMP)+273);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1930,7 +1930,7 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
|
||||
}
|
||||
if (particles[i-1].type==PT_FIRW && particles[i-1].tmp>=2)
|
||||
{
|
||||
int caddress = restrict_flt(restrict_flt((float)(particles[i-1].tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
|
||||
auto caddress = int(restrict_flt(float(particles[i-1].tmp-4), 0.0f, 199.0f))*3;
|
||||
particles[i-1].type = PT_EMBR;
|
||||
particles[i-1].tmp = 1;
|
||||
particles[i-1].ctype = (((firw_data[caddress]))<<16) | (((firw_data[caddress+1]))<<8) | ((firw_data[caddress+2]));
|
||||
@ -2235,7 +2235,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
|
||||
//Store temperature as an offset of 21C(294.15K) or go into a 16byte int and store the whole thing
|
||||
if(fabs(particles[i].temp-294.15f)<127)
|
||||
{
|
||||
tempTemp = floor(particles[i].temp-294.15f+0.5f);
|
||||
tempTemp = int(floor(particles[i].temp-294.15f+0.5f));
|
||||
partsData[partsDataLen++] = tempTemp;
|
||||
}
|
||||
else
|
||||
@ -2581,7 +2581,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
|
||||
bson_append_int(&b, "pmapbits", pmapbits);
|
||||
if (partsData && partsDataLen)
|
||||
{
|
||||
bson_append_binary(&b, "parts", BSON_BIN_USER, (const char *)partsData.get(), partsDataLen);
|
||||
bson_append_binary(&b, "parts", (char)BSON_BIN_USER, (const char *)partsData.get(), partsDataLen);
|
||||
|
||||
if (palette.size())
|
||||
{
|
||||
@ -2594,12 +2594,12 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
|
||||
}
|
||||
|
||||
if (partsPosData && partsPosDataLen)
|
||||
bson_append_binary(&b, "partsPos", BSON_BIN_USER, (const char *)partsPosData.get(), partsPosDataLen);
|
||||
bson_append_binary(&b, "partsPos", (char)BSON_BIN_USER, (const char *)partsPosData.get(), partsPosDataLen);
|
||||
}
|
||||
if (wallData && hasWallData)
|
||||
bson_append_binary(&b, "wallMap", BSON_BIN_USER, (const char *)wallData.get(), wallDataLen);
|
||||
bson_append_binary(&b, "wallMap", (char)BSON_BIN_USER, (const char *)wallData.get(), wallDataLen);
|
||||
if (fanData && fanDataLen)
|
||||
bson_append_binary(&b, "fanMap", BSON_BIN_USER, (const char *)fanData.get(), fanDataLen);
|
||||
bson_append_binary(&b, "fanMap", (char)BSON_BIN_USER, (const char *)fanData.get(), fanDataLen);
|
||||
if (pressData && hasPressure && pressDataLen)
|
||||
bson_append_binary(&b, "pressMap", (char)BSON_BIN_USER, (const char*)pressData.get(), pressDataLen);
|
||||
if (vxData && hasPressure && vxDataLen)
|
||||
@ -2609,7 +2609,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
|
||||
if (ambientData && hasAmbientHeat && this->aheatEnable && ambientDataLen)
|
||||
bson_append_binary(&b, "ambientMap", (char)BSON_BIN_USER, (const char*)ambientData.get(), ambientDataLen);
|
||||
if (soapLinkData && soapLinkDataLen)
|
||||
bson_append_binary(&b, "soapLinks", BSON_BIN_USER, (const char *)soapLinkData, soapLinkDataLen);
|
||||
bson_append_binary(&b, "soapLinks", (char)BSON_BIN_USER, (const char *)soapLinkData, soapLinkDataLen);
|
||||
unsigned int signsCount = 0;
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ namespace http
|
||||
ByteString(user["Location"].asString()).FromUtf8(),
|
||||
user["Website"].asString(),
|
||||
user["Saves"]["Count"].asInt(),
|
||||
user["Saves"]["AverageScore"].asInt(),
|
||||
user["Saves"]["AverageScore"].asFloat(),
|
||||
user["Saves"]["HighestScore"].asInt(),
|
||||
user["Forum"]["Topics"].asInt(),
|
||||
user["Forum"]["Replies"].asInt(),
|
||||
|
@ -33,7 +33,7 @@ void ElementPopulationDebug::Draw()
|
||||
if(sim->elements[i].Enabled)
|
||||
{
|
||||
if(maxVal < sim->elementCount[i])
|
||||
maxVal = sim->elementCount[i];
|
||||
maxVal = float(sim->elementCount[i]);
|
||||
bars++;
|
||||
}
|
||||
}
|
||||
@ -51,8 +51,8 @@ void ElementPopulationDebug::Draw()
|
||||
{
|
||||
if(sim->elements[i].Enabled)
|
||||
{
|
||||
float count = sim->elementCount[i];
|
||||
int barSize = (count * scale - 0.5f);
|
||||
auto count = sim->elementCount[i];
|
||||
auto barSize = int(count * scale - 0.5f);
|
||||
int barX = bars;//*2;
|
||||
|
||||
g->draw_line(xStart+barX, yBottom+3, xStart+barX, yBottom+2, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255);
|
||||
|
@ -46,8 +46,8 @@ VideoBuffer::VideoBuffer(pixel * buffer, int width, int height):
|
||||
|
||||
void VideoBuffer::Resize(float factor, bool resample)
|
||||
{
|
||||
int newWidth = ((float)Width)*factor;
|
||||
int newHeight = ((float)Height)*factor;
|
||||
int newWidth = int(Width * factor);
|
||||
int newHeight = int(Height * factor);
|
||||
Resize(newWidth, newHeight, resample);
|
||||
}
|
||||
|
||||
@ -61,9 +61,9 @@ void VideoBuffer::Resize(int width, int height, bool resample, bool fixedRatio)
|
||||
if(newHeight == -1 || newWidth == -1)
|
||||
{
|
||||
if(newHeight == -1)
|
||||
newHeight = ((float)Height)*((float)newWidth/(float)Width);
|
||||
newHeight = int(float(Height) * newWidth / Width);
|
||||
if(newWidth == -1)
|
||||
newWidth = ((float)Width)*((float)newHeight/(float)Height);
|
||||
newWidth = int(float(Width) * newHeight / Height);
|
||||
}
|
||||
else if(fixedRatio)
|
||||
{
|
||||
@ -164,9 +164,9 @@ char * Graphics::GenerateGradient(pixel * colours, float * points, int pointcoun
|
||||
cccpos = ccpos / (pose - poss);
|
||||
if(cccpos > 1.0f)
|
||||
cccpos = 1.0f;
|
||||
newdata[(cp*3)] = PIXR(colours[i])*(1.0f-cccpos) + PIXR(colours[j])*(cccpos);
|
||||
newdata[(cp*3)+1] = PIXG(colours[i])*(1.0f-cccpos) + PIXG(colours[j])*(cccpos);
|
||||
newdata[(cp*3)+2] = PIXB(colours[i])*(1.0f-cccpos) + PIXB(colours[j])*(cccpos);
|
||||
newdata[(cp*3) ] = char(PIXR(colours[i])*(1.0f-cccpos) + PIXR(colours[j])*(cccpos));
|
||||
newdata[(cp*3)+1] = char(PIXG(colours[i])*(1.0f-cccpos) + PIXG(colours[j])*(cccpos));
|
||||
newdata[(cp*3)+2] = char(PIXB(colours[i])*(1.0f-cccpos) + PIXB(colours[j])*(cccpos));
|
||||
}
|
||||
return newdata;
|
||||
}
|
||||
|
@ -1348,10 +1348,10 @@ void Renderer::render_parts()
|
||||
if((elements[t].Properties & PROP_HOT_GLOW) && sim->parts[i].temp>(elements[t].HighTemperature-800.0f))
|
||||
{
|
||||
gradv = 3.1415/(2*elements[t].HighTemperature-(elements[t].HighTemperature-800.0f));
|
||||
caddress = (sim->parts[i].temp>elements[t].HighTemperature)?elements[t].HighTemperature-(elements[t].HighTemperature-800.0f):sim->parts[i].temp-(elements[t].HighTemperature-800.0f);
|
||||
colr += sin(gradv*caddress) * 226;;
|
||||
colg += sin(gradv*caddress*4.55 +3.14) * 34;
|
||||
colb += sin(gradv*caddress*2.22 +3.14) * 64;
|
||||
caddress = int((sim->parts[i].temp>elements[t].HighTemperature)?elements[t].HighTemperature-(elements[t].HighTemperature-800.0f):sim->parts[i].temp-(elements[t].HighTemperature-800.0f));
|
||||
colr += int(sin(gradv*caddress) * 226);
|
||||
colg += int(sin(gradv*caddress*4.55 +3.14) * 34);
|
||||
colb += int(sin(gradv*caddress*2.22 +3.14) * 64);
|
||||
}
|
||||
|
||||
if((pixel_mode & FIRE_ADD) && !(render_mode & FIRE_ADD))
|
||||
@ -1370,7 +1370,9 @@ void Renderer::render_parts()
|
||||
//Alter colour based on display mode
|
||||
if(colour_mode & COLOUR_HEAT)
|
||||
{
|
||||
caddress = restrict_flt((int)( restrict_flt((float)(sim->parts[i].temp+(-MIN_TEMP)), 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
|
||||
constexpr float min_temp = MIN_TEMP;
|
||||
constexpr float max_temp = MAX_TEMP;
|
||||
caddress = int(restrict_flt((sim->parts[i].temp - min_temp) / (max_temp - min_temp) * 1024, 0, 1023)) * 3;
|
||||
firea = 255;
|
||||
firer = colr = color_data[caddress];
|
||||
fireg = colg = color_data[caddress+1];
|
||||
@ -1387,10 +1389,10 @@ void Renderer::render_parts()
|
||||
{
|
||||
gradv = 0.4f;
|
||||
if (!(sim->parts[i].life<5))
|
||||
q = sqrt((float)sim->parts[i].life);
|
||||
q = int(sqrt((float)sim->parts[i].life));
|
||||
else
|
||||
q = sim->parts[i].life;
|
||||
colr = colg = colb = sin(gradv*q) * 100 + 128;
|
||||
colr = colg = colb = int(sin(gradv*q) * 100 + 128);
|
||||
cola = 255;
|
||||
if(pixel_mode & (FIREMODE | PMODE_GLOW))
|
||||
pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR;
|
||||
@ -1448,11 +1450,11 @@ void Renderer::render_parts()
|
||||
|
||||
if (colour_mode & COLOUR_GRAD)
|
||||
{
|
||||
float frequency = 0.05;
|
||||
int q = sim->parts[i].temp-40;
|
||||
colr = sin(frequency*q) * 16 + colr;
|
||||
colg = sin(frequency*q) * 16 + colg;
|
||||
colb = sin(frequency*q) * 16 + colb;
|
||||
auto frequency = 0.05f;
|
||||
auto q = int(sim->parts[i].temp-40);
|
||||
colr = int(sin(frequency*q) * 16 + colr);
|
||||
colg = int(sin(frequency*q) * 16 + colg);
|
||||
colb = int(sin(frequency*q) * 16 + colb);
|
||||
if(pixel_mode & (FIREMODE | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR;
|
||||
}
|
||||
|
||||
@ -1625,15 +1627,15 @@ void Renderer::render_parts()
|
||||
draw_line(nx+2, ny-2, nx+2, ny+2, colr, colg, colb, 255);
|
||||
}
|
||||
//legs
|
||||
draw_line(nx, ny+3, cplayer->legs[0], cplayer->legs[1], legr, legg, legb, 255);
|
||||
draw_line(cplayer->legs[0], cplayer->legs[1], cplayer->legs[4], cplayer->legs[5], legr, legg, legb, 255);
|
||||
draw_line(nx, ny+3, cplayer->legs[8], cplayer->legs[9], legr, legg, legb, 255);
|
||||
draw_line(cplayer->legs[8], cplayer->legs[9], cplayer->legs[12], cplayer->legs[13], legr, legg, legb, 255);
|
||||
draw_line(nx, ny+3, int(cplayer->legs[0]), int(cplayer->legs[1]), legr, legg, legb, 255);
|
||||
draw_line(int(cplayer->legs[0]), int(cplayer->legs[1]), int(cplayer->legs[4]), int(cplayer->legs[5]), legr, legg, legb, 255);
|
||||
draw_line(nx, ny+3, int(cplayer->legs[8]), int(cplayer->legs[9]), legr, legg, legb, 255);
|
||||
draw_line(int(cplayer->legs[8]), int(cplayer->legs[9]), int(cplayer->legs[12]), int(cplayer->legs[13]), legr, legg, legb, 255);
|
||||
if (cplayer->rocketBoots)
|
||||
{
|
||||
for (int leg=0; leg<2; leg++)
|
||||
{
|
||||
int nx = cplayer->legs[leg*8+4], ny = cplayer->legs[leg*8+5];
|
||||
int nx = int(cplayer->legs[leg*8+4]), ny = int(cplayer->legs[leg*8+5]);
|
||||
int colr = 255, colg = 0, colb = 255;
|
||||
if (((int)(cplayer->comm)&0x04) == 0x04 || (((int)(cplayer->comm)&0x01) == 0x01 && leg==0) || (((int)(cplayer->comm)&0x02) == 0x02 && leg==1))
|
||||
blendpixel(nx, ny, 0, 255, 0, 255);
|
||||
@ -1779,7 +1781,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if(pixel_mode & PMODE_SPARK)
|
||||
{
|
||||
flicker = random_gen()%20;
|
||||
flicker = float(random_gen()%20);
|
||||
#ifdef OGLR
|
||||
//Oh god, this is awful
|
||||
lineC[clineC++] = ((float)colr)/255.0f;
|
||||
@ -1832,18 +1834,18 @@ void Renderer::render_parts()
|
||||
#else
|
||||
gradv = 4*sim->parts[i].life + flicker;
|
||||
for (x = 0; gradv>0.5; x++) {
|
||||
addpixel(nx+x, ny, colr, colg, colb, gradv);
|
||||
addpixel(nx-x, ny, colr, colg, colb, gradv);
|
||||
addpixel(nx+x, ny, colr, colg, colb, int(gradv));
|
||||
addpixel(nx-x, ny, colr, colg, colb, int(gradv));
|
||||
|
||||
addpixel(nx, ny+x, colr, colg, colb, gradv);
|
||||
addpixel(nx, ny-x, colr, colg, colb, gradv);
|
||||
addpixel(nx, ny+x, colr, colg, colb, int(gradv));
|
||||
addpixel(nx, ny-x, colr, colg, colb, int(gradv));
|
||||
gradv = gradv/1.5f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(pixel_mode & PMODE_FLARE)
|
||||
{
|
||||
flicker = random_gen()%20;
|
||||
flicker = float(random_gen()%20);
|
||||
#ifdef OGLR
|
||||
//Oh god, this is awful
|
||||
lineC[clineC++] = ((float)colr)/255.0f;
|
||||
@ -1895,28 +1897,28 @@ void Renderer::render_parts()
|
||||
cline++;
|
||||
#else
|
||||
gradv = flicker + fabs(parts[i].vx)*17 + fabs(sim->parts[i].vy)*17;
|
||||
blendpixel(nx, ny, colr, colg, colb, (gradv*4)>255?255:(gradv*4) );
|
||||
blendpixel(nx+1, ny, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx-1, ny, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx, ny+1, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx, ny-1, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx, ny, colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) );
|
||||
blendpixel(nx+1, ny, colr, colg, colb,int( (gradv*2)>255?255:(gradv*2)) );
|
||||
blendpixel(nx-1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
blendpixel(nx, ny+1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
blendpixel(nx, ny-1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
if (gradv>255) gradv=255;
|
||||
blendpixel(nx+1, ny-1, colr, colg, colb, gradv);
|
||||
blendpixel(nx-1, ny-1, colr, colg, colb, gradv);
|
||||
blendpixel(nx+1, ny+1, colr, colg, colb, gradv);
|
||||
blendpixel(nx-1, ny+1, colr, colg, colb, gradv);
|
||||
blendpixel(nx+1, ny-1, colr, colg, colb, int(gradv));
|
||||
blendpixel(nx-1, ny-1, colr, colg, colb, int(gradv));
|
||||
blendpixel(nx+1, ny+1, colr, colg, colb, int(gradv));
|
||||
blendpixel(nx-1, ny+1, colr, colg, colb, int(gradv));
|
||||
for (x = 1; gradv>0.5; x++) {
|
||||
addpixel(nx+x, ny, colr, colg, colb, gradv);
|
||||
addpixel(nx-x, ny, colr, colg, colb, gradv);
|
||||
addpixel(nx, ny+x, colr, colg, colb, gradv);
|
||||
addpixel(nx, ny-x, colr, colg, colb, gradv);
|
||||
addpixel(nx+x, ny, colr, colg, colb, int(gradv));
|
||||
addpixel(nx-x, ny, colr, colg, colb, int(gradv));
|
||||
addpixel(nx, ny+x, colr, colg, colb, int(gradv));
|
||||
addpixel(nx, ny-x, colr, colg, colb, int(gradv));
|
||||
gradv = gradv/1.2f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(pixel_mode & PMODE_LFLARE)
|
||||
{
|
||||
flicker = random_gen()%20;
|
||||
flicker = float(random_gen()%20);
|
||||
#ifdef OGLR
|
||||
//Oh god, this is awful
|
||||
lineC[clineC++] = ((float)colr)/255.0f;
|
||||
@ -1968,21 +1970,21 @@ void Renderer::render_parts()
|
||||
cline++;
|
||||
#else
|
||||
gradv = flicker + fabs(parts[i].vx)*17 + fabs(parts[i].vy)*17;
|
||||
blendpixel(nx, ny, colr, colg, colb, (gradv*4)>255?255:(gradv*4) );
|
||||
blendpixel(nx+1, ny, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx-1, ny, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx, ny+1, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx, ny-1, colr, colg, colb, (gradv*2)>255?255:(gradv*2) );
|
||||
blendpixel(nx, ny, colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) );
|
||||
blendpixel(nx+1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
blendpixel(nx-1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
blendpixel(nx, ny+1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
blendpixel(nx, ny-1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
if (gradv>255) gradv=255;
|
||||
blendpixel(nx+1, ny-1, colr, colg, colb, gradv);
|
||||
blendpixel(nx-1, ny-1, colr, colg, colb, gradv);
|
||||
blendpixel(nx+1, ny+1, colr, colg, colb, gradv);
|
||||
blendpixel(nx-1, ny+1, colr, colg, colb, gradv);
|
||||
blendpixel(nx+1, ny-1, colr, colg, colb, int(gradv));
|
||||
blendpixel(nx-1, ny-1, colr, colg, colb, int(gradv));
|
||||
blendpixel(nx+1, ny+1, colr, colg, colb, int(gradv));
|
||||
blendpixel(nx-1, ny+1, colr, colg, colb, int(gradv));
|
||||
for (x = 1; gradv>0.5; x++) {
|
||||
addpixel(nx+x, ny, colr, colg, colb, gradv);
|
||||
addpixel(nx-x, ny, colr, colg, colb, gradv);
|
||||
addpixel(nx, ny+x, colr, colg, colb, gradv);
|
||||
addpixel(nx, ny-x, colr, colg, colb, gradv);
|
||||
addpixel(nx+x, ny, colr, colg, colb, int(gradv));
|
||||
addpixel(nx-x, ny, colr, colg, colb, int(gradv));
|
||||
addpixel(nx, ny+x, colr, colg, colb, int(gradv));
|
||||
addpixel(nx, ny-x, colr, colg, colb, int(gradv));
|
||||
gradv = gradv/1.01f;
|
||||
}
|
||||
#endif
|
||||
@ -2322,8 +2324,8 @@ void Renderer::draw_other() // EMP effect
|
||||
glTranslated(0, -MENUSIZE, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
|
||||
#else
|
||||
int r=emp_decor*2.5, g=100+emp_decor*1.5, b=255;
|
||||
int a=(1.0*emp_decor/110)*255;
|
||||
int r=int(emp_decor*2.5), g=int(100+emp_decor*1.5), b=255;
|
||||
int a=int((1.0*emp_decor/110)*255);
|
||||
if (r>255) r=255;
|
||||
if (g>255) g=255;
|
||||
if (b>255) g=255;
|
||||
@ -2353,8 +2355,8 @@ void Renderer::draw_grav()
|
||||
ca = y*(XRES/CELL)+x;
|
||||
if(fabsf(sim->gravx[ca]) <= 0.001f && fabsf(sim->gravy[ca]) <= 0.001f)
|
||||
continue;
|
||||
nx = x*CELL;
|
||||
ny = y*CELL;
|
||||
nx = float(x*CELL);
|
||||
ny = float(y*CELL);
|
||||
dist = fabsf(sim->gravy[ca])+fabsf(sim->gravx[ca]);
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
@ -2397,8 +2399,9 @@ void Renderer::draw_air()
|
||||
}
|
||||
else if (display_mode & DISPLAY_AIRH)
|
||||
{
|
||||
float ttemp = hv[y][x]+(-MIN_TEMP);
|
||||
int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
|
||||
constexpr float min_temp = MIN_TEMP;
|
||||
constexpr float max_temp = MAX_TEMP;
|
||||
int caddress = int(restrict_flt((hv[y][x] - min_temp) / (max_temp - min_temp), 0, 1023)) * 3;
|
||||
c = PIXRGB((int)(color_data[caddress]*0.7f), (int)(color_data[caddress+1]*0.7f), (int)(color_data[caddress+2]*0.7f));
|
||||
//c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
|
||||
// clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green
|
||||
|
@ -105,7 +105,7 @@ void ColourPickerActivity::OnMouseMove(int x, int y, int dx, int dy)
|
||||
x -= Position.X+5;
|
||||
y -= Position.Y+5;
|
||||
|
||||
currentHue = (float(x)/float(255))*359.0f;
|
||||
currentHue = int((float(x)/float(255))*359.0f);
|
||||
currentSaturation = 255-(y*2);
|
||||
|
||||
if(currentSaturation > 255)
|
||||
@ -146,7 +146,7 @@ void ColourPickerActivity::OnMouseDown(int x, int y, unsigned button)
|
||||
if(x >= 0 && x < 256 && y >= 0 && y <= 128)
|
||||
{
|
||||
mouseDown = true;
|
||||
currentHue = (float(x)/float(255))*359.0f;
|
||||
currentHue = int((float(x)/float(255))*359.0f);
|
||||
currentSaturation = 255-(y*2);
|
||||
|
||||
if(currentSaturation > 255)
|
||||
@ -193,7 +193,7 @@ void ColourPickerActivity::OnMouseUp(int x, int y, unsigned button)
|
||||
x -= Position.X+5;
|
||||
y -= Position.Y+5;
|
||||
|
||||
currentHue = (float(x)/float(255))*359.0f;
|
||||
currentHue = int((float(x)/float(255))*359.0f);
|
||||
currentSaturation = 255-(y*2);
|
||||
|
||||
if(currentSaturation > 255)
|
||||
@ -261,7 +261,7 @@ void ColourPickerActivity::OnDraw()
|
||||
{
|
||||
for(int hue = 0; hue <= 359; hue++)
|
||||
{
|
||||
currx = clamp_flt(hue, 0, 359)+offsetX;
|
||||
currx = int(restrict_flt(float(hue), 0, 359))+offsetX;
|
||||
if (currx == lastx)
|
||||
continue;
|
||||
lastx = currx;
|
||||
@ -286,7 +286,7 @@ void ColourPickerActivity::OnDraw()
|
||||
}
|
||||
|
||||
//draw color square pointer
|
||||
int currentHueX = clamp_flt(currentHue, 0, 359);
|
||||
int currentHueX = int(restrict_flt(float(currentHue), 0, 359));
|
||||
int currentSaturationY = ((255-currentSaturation)/2);
|
||||
g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY-5, offsetX+currentHueX, offsetY+currentSaturationY-1);
|
||||
g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY+1, offsetX+currentHueX, offsetY+currentSaturationY+5);
|
||||
@ -294,7 +294,7 @@ void ColourPickerActivity::OnDraw()
|
||||
g->xor_line(offsetX+currentHueX+1, offsetY+currentSaturationY, offsetX+currentHueX+5, offsetY+currentSaturationY);
|
||||
|
||||
//draw brightness bar pointer
|
||||
int currentValueX = restrict_flt(currentValue, 0, 254);
|
||||
int currentValueX = int(restrict_flt(float(currentValue), 0, 254));
|
||||
g->xor_line(offsetX+currentValueX, offsetY+4+128, offsetX+currentValueX, offsetY+13+128);
|
||||
g->xor_line(offsetX+currentValueX+1, offsetY+4+128, offsetX+currentValueX+1, offsetY+13+128);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ void FileBrowserActivity::OnTick(float dt)
|
||||
});
|
||||
|
||||
progressBar->SetStatus("Rendering thumbnails");
|
||||
progressBar->SetProgress((float(totalFiles-files.size())/float(totalFiles))*100.0f);
|
||||
progressBar->SetProgress(totalFiles ? (totalFiles - files.size()) * 100 / totalFiles : 0);
|
||||
componentsQueue.push_back(saveButton);
|
||||
fileX++;
|
||||
}
|
||||
|
@ -55,18 +55,18 @@ void BitmapBrush::GenerateBitmap()
|
||||
float originalY = ((float)y)*factorY;
|
||||
float originalX = ((float)x)*factorX;
|
||||
|
||||
int lowerX = std::floor(originalX);
|
||||
int upperX = std::min((float)(origSize.X-1), std::floor(originalX+1.0f));
|
||||
int lowerY = std::floor(originalY);
|
||||
int upperY = std::min((float)(origSize.Y-1), std::floor(originalY+1.0f));
|
||||
auto lowerX = int(std::floor(originalX));
|
||||
auto upperX = int(std::min((float)(origSize.X-1), std::floor(originalX+1.0f)));
|
||||
auto lowerY = int(std::floor(originalY));
|
||||
auto upperY = int(std::min((float)(origSize.Y-1), std::floor(originalY+1.0f)));
|
||||
|
||||
unsigned char topRight = origBitmap[(lowerY*origSize.X)+upperX];
|
||||
unsigned char topLeft = origBitmap[(lowerY*origSize.X)+lowerX];
|
||||
unsigned char bottomRight = origBitmap[(upperY*origSize.X)+upperX];
|
||||
unsigned char bottomLeft = origBitmap[(upperY*origSize.X)+lowerX];
|
||||
float top = LinearInterpolate<float>(topLeft, topRight, lowerX, upperX, originalX);
|
||||
float bottom = LinearInterpolate<float>(bottomLeft, bottomRight, lowerX, upperX, originalX);
|
||||
float mid = LinearInterpolate<float>(top, bottom, lowerY, upperY, originalY);
|
||||
float top = LinearInterpolate<float>(topLeft, topRight, float(lowerX), float(upperX), originalX);
|
||||
float bottom = LinearInterpolate<float>(bottomLeft, bottomRight, float(lowerX), float(upperX), originalX);
|
||||
float mid = LinearInterpolate<float>(top, bottom, float(lowerY), float(upperY), originalY);
|
||||
bitmap[(y*size.X)+x] = mid > 128 ? 255 : 0;
|
||||
}
|
||||
}
|
||||
|
@ -200,9 +200,9 @@ void GOLWindow::OnDraw()
|
||||
auto f = xx / (float)width;
|
||||
for (int yy = 0; yy < 16; ++yy)
|
||||
{
|
||||
int rr = highColour.Red * (1.f - f) + lowColour.Red * f;
|
||||
int gg = highColour.Green * (1.f - f) + lowColour.Green * f;
|
||||
int bb = highColour.Blue * (1.f - f) + lowColour.Blue * f;
|
||||
auto rr = int(highColour.Red * (1.f - f) + lowColour.Red * f);
|
||||
auto gg = int(highColour.Green * (1.f - f) + lowColour.Green * f);
|
||||
auto bb = int(highColour.Blue * (1.f - f) + lowColour.Blue * f);
|
||||
g->blendpixel(Position.X + xx + 30, Position.Y + yy + 67, rr, gg, bb, 255);
|
||||
}
|
||||
}
|
||||
|
@ -485,12 +485,12 @@ void GameController::LoadStamp(GameSave *stamp)
|
||||
|
||||
void GameController::TranslateSave(ui::Point point)
|
||||
{
|
||||
vector2d translate = v2d_new(point.X, point.Y);
|
||||
vector2d translate = v2d_new(float(point.X), float(point.Y));
|
||||
vector2d translated = gameModel->GetPlaceSave()->Translate(translate);
|
||||
ui::Point currentPlaceSaveOffset = gameView->GetPlaceSaveOffset();
|
||||
// resets placeSaveOffset to 0, which is why we back it up first
|
||||
gameModel->SetPlaceSave(gameModel->GetPlaceSave());
|
||||
gameView->SetPlaceSaveOffset(ui::Point(translated.x, translated.y) + currentPlaceSaveOffset);
|
||||
gameView->SetPlaceSaveOffset(ui::Point(int(translated.x), int(translated.y)) + currentPlaceSaveOffset);
|
||||
}
|
||||
|
||||
void GameController::TransformSave(matrix2d transform)
|
||||
|
@ -481,7 +481,7 @@ void GameModel::BuildBrushList()
|
||||
std::cout << "Brushes: Skipping " << brushFiles[i] << ". Could not open" << std::endl;
|
||||
continue;
|
||||
}
|
||||
size_t dimension = std::sqrt((float)brushData.size());
|
||||
auto dimension = size_t(std::sqrt(float(brushData.size())));
|
||||
if (dimension * dimension != brushData.size())
|
||||
{
|
||||
std::cout << "Brushes: Skipping " << brushFiles[i] << ". Invalid bitmap size" << std::endl;
|
||||
|
@ -929,9 +929,9 @@ void GameView::updateToolButtonScroll()
|
||||
|
||||
scrollBar->Position.X = (int)(((float)mouseX/((float)XRES))*(float)(XRES-scrollSize));
|
||||
|
||||
float overflow = totalWidth-(XRES-BARSIZE), mouseLocation = float(XRES-3)/float((XRES-2)-mouseX); //mouseLocation adjusted slightly in case you have 200 elements in one menu
|
||||
float overflow = float(totalWidth-(XRES-BARSIZE)), mouseLocation = float(XRES-3)/float((XRES-2)-mouseX); //mouseLocation adjusted slightly in case you have 200 elements in one menu
|
||||
|
||||
newInitialX += overflow/mouseLocation;
|
||||
newInitialX += int(overflow/mouseLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1616,7 +1616,7 @@ void GameView::OnTick(float dt)
|
||||
|
||||
if(introText)
|
||||
{
|
||||
introText -= int(dt)>0?((int)dt < 5? dt:5):1;
|
||||
introText -= int(dt)>0?(int(dt) < 5? int(dt):5):1;
|
||||
if(introText < 0)
|
||||
introText = 0;
|
||||
}
|
||||
@ -2107,7 +2107,7 @@ void GameView::OnDraw()
|
||||
String sampleInfo = String::Build("#", screenshotIndex, " ", String(0xE00E), " REC");
|
||||
|
||||
int textWidth = Graphics::textwidth(sampleInfo);
|
||||
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
|
||||
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 127);
|
||||
g->drawtext(XRES-16-textWidth, 16, sampleInfo, 255, 50, 20, 255);
|
||||
}
|
||||
else if(showHud)
|
||||
@ -2220,8 +2220,8 @@ void GameView::OnDraw()
|
||||
}
|
||||
|
||||
int textWidth = Graphics::textwidth(sampleInfo.Build());
|
||||
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5f);
|
||||
g->drawtext(XRES-16-textWidth, 16, sampleInfo.Build(), 255, 255, 255, alpha*0.75f);
|
||||
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5f));
|
||||
g->drawtext(XRES-16-textWidth, 16, sampleInfo.Build(), 255, 255, 255, int(alpha*0.75f));
|
||||
|
||||
#ifndef OGLI
|
||||
if (wavelengthGfx)
|
||||
@ -2277,8 +2277,8 @@ void GameView::OnDraw()
|
||||
sampleInfo << ", AHeat: " << sample.AirTemperature - 273.15f << " C";
|
||||
|
||||
textWidth = Graphics::textwidth(sampleInfo.Build());
|
||||
g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, alpha*0.5f);
|
||||
g->drawtext(XRES-16-textWidth, 30, sampleInfo.Build(), 255, 255, 255, alpha*0.75f);
|
||||
g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, int(alpha*0.5f));
|
||||
g->drawtext(XRES-16-textWidth, 30, sampleInfo.Build(), 255, 255, 255, int(alpha*0.75f));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2306,8 +2306,8 @@ void GameView::OnDraw()
|
||||
|
||||
int textWidth = Graphics::textwidth(fpsInfo.Build());
|
||||
int alpha = 255-introText*5;
|
||||
g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5);
|
||||
g->drawtext(16, 16, fpsInfo.Build(), 32, 216, 255, alpha*0.75);
|
||||
g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5));
|
||||
g->drawtext(16, 16, fpsInfo.Build(), 32, 216, 255, int(alpha*0.75));
|
||||
}
|
||||
|
||||
//Tooltips
|
||||
|
@ -70,7 +70,7 @@ sim(sim_)
|
||||
property = new ui::DropDown(ui::Point(8, 25), ui::Point(Size.X-16, 16));
|
||||
property->SetActionCallback({ [this] { FocusComponent(textField); } });
|
||||
AddComponent(property);
|
||||
for (size_t i = 0; i < properties.size(); i++)
|
||||
for (int i = 0; i < int(properties.size()); i++)
|
||||
{
|
||||
property->AddOption(std::pair<String, int>(properties[i].Name.FromAscii(), i));
|
||||
}
|
||||
@ -251,7 +251,7 @@ void PropertyTool::SetProperty(Simulation *sim, ui::Point position)
|
||||
|
||||
if (changeType)
|
||||
{
|
||||
sim->part_change_type(ID(i), sim->parts[ID(i)].x+0.5f, sim->parts[ID(i)].y+0.5f, propValue.Integer);
|
||||
sim->part_change_type(ID(i), int(sim->parts[ID(i)].x+0.5f), int(sim->parts[ID(i)].y+0.5f), propValue.Integer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ void Engine::Draw()
|
||||
memcpy(g->vid, lastBuffer, (width_ * height_) * PIXELSIZE);
|
||||
if(windowOpenState < 20)
|
||||
windowOpenState++;
|
||||
g->fillrect(0, 0, width_, height_, 0, 0, 0, 255-std::pow(.98, windowOpenState)*255);
|
||||
g->fillrect(0, 0, width_, height_, 0, 0, 0, int(255-std::pow(.98, windowOpenState)*255));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -56,17 +56,17 @@ void ProgressBar::Draw(const Point & screenPos)
|
||||
progress = 100;
|
||||
float size = float(Size.X-4)*(float(progress)/100.0f); // TIL...
|
||||
size = std::min(std::max(size, 0.0f), float(Size.X-4));
|
||||
g->fillrect(screenPos.X + 2, screenPos.Y + 2, size, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
g->fillrect(screenPos.X + 2, screenPos.Y + 2, int(size), Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
}
|
||||
} else {
|
||||
int size = 40, rsize = 0;
|
||||
float position = float(Size.X-4)*(intermediatePos/100.0f);
|
||||
if(position + size - 1 > Size.X-4)
|
||||
{
|
||||
size = (Size.X-4)-position+1;
|
||||
size = int((Size.X-4)-position+1);
|
||||
rsize = 40-size;
|
||||
}
|
||||
g->fillrect(screenPos.X + 2 + position, screenPos.Y + 2, size, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
g->fillrect(screenPos.X + 2 + int(position), screenPos.Y + 2, size, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
if(rsize)
|
||||
{
|
||||
g->fillrect(screenPos.X + 2, screenPos.Y + 2, rsize, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
|
@ -129,7 +129,7 @@ void SaveButton::Tick(float dt)
|
||||
if (!triedThumbnail)
|
||||
{
|
||||
float scaleFactor = (Size.Y-25)/((float)YRES);
|
||||
ui::Point thumbBoxSize = ui::Point(((float)XRES)*scaleFactor, ((float)YRES)*scaleFactor);
|
||||
ui::Point thumbBoxSize = ui::Point(int(XRES*scaleFactor), int(YRES*scaleFactor));
|
||||
if (save)
|
||||
{
|
||||
if(save->GetGameSave())
|
||||
@ -176,7 +176,7 @@ void SaveButton::Draw(const Point& screenPos)
|
||||
{
|
||||
Graphics * g = GetGraphics();
|
||||
float scaleFactor = (Size.Y-25)/((float)YRES);
|
||||
ui::Point thumbBoxSize = ui::Point(((float)XRES)*scaleFactor, ((float)YRES)*scaleFactor);
|
||||
ui::Point thumbBoxSize = ui::Point(int(XRES*scaleFactor), int(YRES*scaleFactor));
|
||||
|
||||
wantsDraw = true;
|
||||
|
||||
|
@ -37,7 +37,7 @@ int ScrollPanel::GetScrollLimit()
|
||||
|
||||
void ScrollPanel::SetScrollPosition(int position)
|
||||
{
|
||||
offsetY = position;
|
||||
offsetY = float(position);
|
||||
ViewportPosition.Y = -position;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ void ScrollPanel::Draw(const Point& screenPos)
|
||||
}
|
||||
|
||||
g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y, scrollBarWidth, Size.Y, 125, 125, 125, 100);
|
||||
g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y+scrollPos, scrollBarWidth, scrollHeight+1, 255, 255, 255, 255);
|
||||
g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y+int(scrollPos), scrollBarWidth, int(scrollHeight)+1, 255, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ void ScrollPanel::XOnMouseClick(int x, int y, unsigned int button)
|
||||
if (isMouseInsideScrollbar)
|
||||
{
|
||||
scrollbarSelected = true;
|
||||
scrollbarInitialYOffset = offsetY;
|
||||
scrollbarInitialYOffset = int(offsetY);
|
||||
}
|
||||
scrollbarInitialYClick = y;
|
||||
scrollbarClickLocation = 100;
|
||||
@ -105,14 +105,14 @@ void ScrollPanel::XOnMouseMoved(int x, int y, int dx, int dy)
|
||||
{
|
||||
if (x > 0)
|
||||
{
|
||||
int scrollY = float(y-scrollbarInitialYClick)/float(Size.Y)*float(InnerSize.Y)+scrollbarInitialYOffset;
|
||||
auto scrollY = int(float(y-scrollbarInitialYClick)/float(Size.Y)*float(InnerSize.Y)+scrollbarInitialYOffset);
|
||||
ViewportPosition.Y = -scrollY;
|
||||
offsetY = scrollY;
|
||||
offsetY = float(scrollY);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewportPosition.Y = -scrollbarInitialYOffset;
|
||||
offsetY = scrollbarInitialYOffset;
|
||||
offsetY = float(scrollbarInitialYOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ void ScrollPanel::XTick(float dt)
|
||||
maxOffset.Y = std::max(0, maxOffset.Y);
|
||||
maxOffset.X = std::max(0, maxOffset.X);
|
||||
|
||||
int oldOffsetY = offsetY;
|
||||
auto oldOffsetY = int(offsetY);
|
||||
offsetY += yScrollVel;
|
||||
offsetX += xScrollVel;
|
||||
|
||||
@ -165,10 +165,10 @@ void ScrollPanel::XTick(float dt)
|
||||
}
|
||||
else if (offsetY>maxOffset.Y)
|
||||
{
|
||||
offsetY = maxOffset.Y;
|
||||
offsetY = float(maxOffset.Y);
|
||||
yScrollVel = 0;
|
||||
}
|
||||
ViewportPosition.Y = -offsetY;
|
||||
ViewportPosition.Y = -int(offsetY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -176,12 +176,12 @@ void ScrollPanel::XTick(float dt)
|
||||
{
|
||||
offsetY = 0;
|
||||
yScrollVel = 0;
|
||||
ViewportPosition.Y = -offsetY;
|
||||
ViewportPosition.Y = -int(offsetY);
|
||||
}
|
||||
else if (offsetY>maxOffset.Y)
|
||||
{
|
||||
offsetY = maxOffset.Y;
|
||||
ViewportPosition.Y = -offsetY;
|
||||
offsetY = float(maxOffset.Y);
|
||||
ViewportPosition.Y = -int(offsetY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,6 +205,6 @@ void ScrollPanel::XTick(float dt)
|
||||
scrollbarClickLocation = 0;
|
||||
|
||||
offsetY += scrollbarClickLocation*scrollHeight/10;
|
||||
ViewportPosition.Y -= scrollbarClickLocation*scrollHeight/10;
|
||||
ViewportPosition.Y -= int(scrollbarClickLocation*scrollHeight/10);
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ void Slider::updatePosition(int position)
|
||||
if(position > Size.X-3)
|
||||
position = Size.X-3;
|
||||
|
||||
float fPosition = position-3;
|
||||
float fSize = Size.X-6;
|
||||
auto fPosition = float(position-3);
|
||||
auto fSize = float(Size.X-6);
|
||||
|
||||
float fSliderPosition = (fPosition/fSize)*sliderSteps;//position;//((x-3)/(Size.X-6))*sliderSteps;
|
||||
|
||||
int newSliderPosition = fSliderPosition;
|
||||
auto newSliderPosition = int(fSliderPosition);
|
||||
|
||||
if(newSliderPosition == sliderPosition)
|
||||
return;
|
||||
@ -120,12 +120,12 @@ void Slider::Draw(const Point& screenPos)
|
||||
|
||||
g->drawrect(screenPos.X+3, screenPos.Y+3, Size.X-6, Size.Y-6, 255, 255, 255, 255);
|
||||
|
||||
float fPosition = sliderPosition;
|
||||
float fSize = Size.X-6;
|
||||
float fSteps = sliderSteps;
|
||||
auto fPosition = float(sliderPosition);
|
||||
auto fSize = float(Size.X-6);
|
||||
auto fSteps = float(sliderSteps);
|
||||
|
||||
float fSliderX = (fSize/fSteps)*fPosition;//sliderPosition;//((Size.X-6)/sliderSteps)*sliderPosition;
|
||||
int sliderX = fSliderX;
|
||||
auto fSliderX = (fSize/fSteps)*fPosition;//sliderPosition;//((Size.X-6)/sliderSteps)*sliderPosition;
|
||||
auto sliderX = int(fSliderX);
|
||||
sliderX += 3;
|
||||
|
||||
g->fillrect(screenPos.X+sliderX-2, screenPos.Y+1, 4, Size.Y-2, 20, 20, 20, 255);
|
||||
|
@ -30,7 +30,7 @@ void Spinner::Draw(const Point& screenPos)
|
||||
for(float t = 0.0f; t < 6.0f; t+=0.25f)
|
||||
{
|
||||
//g->drawblob(baseX+(sin(cValue+t)*(Size.X/2)), baseY+(cos(cValue+t)*(Size.X/2)), t*255, t*255, t*255);
|
||||
g->draw_line(baseX+(sin(cValue+t)*lineInner), baseY+(cos(cValue+t)*lineInner), baseX+(sin(cValue+t)*lineOuter), baseY+(cos(cValue+t)*lineOuter), (t/6)*255, (t/6)*255, (t/6)*255, 255);
|
||||
g->draw_line(int(baseX+(sin(cValue+t)*lineInner)), int(baseY+(cos(cValue+t)*lineInner)), int(baseX+(sin(cValue+t)*lineOuter)), int(baseY+(cos(cValue+t)*lineOuter)), int((t/6)*255), int((t/6)*255), int((t/6)*255), 255);
|
||||
}
|
||||
}
|
||||
Spinner::~Spinner()
|
||||
|
@ -59,7 +59,7 @@ void LocalBrowserController::removeSelectedC()
|
||||
{
|
||||
notifyStatus(String::Build("Deleting stamp [", saves[i].FromUtf8(), "] ..."));
|
||||
Client::Ref().DeleteStamp(saves[i]);
|
||||
notifyProgress((float(i+1)/float(saves.size())*100));
|
||||
notifyProgress((i + 1) * 100 / saves.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -176,9 +176,9 @@ void PreviewView::commentBoxAutoHeight()
|
||||
|
||||
commentBoxHeight = newSize+22;
|
||||
commentBoxPositionX = (XRES/2)+4;
|
||||
commentBoxPositionY = Size.Y-(newSize+21);
|
||||
commentBoxSizeX = Size.X-(XRES/2)-8;
|
||||
commentBoxSizeY = newSize;
|
||||
commentBoxPositionY = float(Size.Y-(newSize+21));
|
||||
commentBoxSizeX = float(Size.X-(XRES/2)-8);
|
||||
commentBoxSizeY = float(newSize);
|
||||
|
||||
if (commentWarningLabel && commentHelpText && !commentWarningLabel->Visible && addCommentBox->Position.Y+addCommentBox->Size.Y < Size.Y-14)
|
||||
{
|
||||
@ -191,8 +191,8 @@ void PreviewView::commentBoxAutoHeight()
|
||||
addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
|
||||
commentBoxPositionX = (XRES/2)+4;
|
||||
commentBoxPositionY = Size.Y-19;
|
||||
commentBoxSizeX = Size.X-(XRES/2)-48;
|
||||
commentBoxPositionY = float(Size.Y-19);
|
||||
commentBoxSizeX = float(Size.X-(XRES/2)-48);
|
||||
commentBoxSizeY = 17;
|
||||
|
||||
if (commentWarningLabel && commentWarningLabel->Visible)
|
||||
@ -299,14 +299,14 @@ void PreviewView::OnDraw()
|
||||
if (50>lv)
|
||||
{
|
||||
ryf = 50.0f/((float)lv);
|
||||
nyu = votesUp*ryf;
|
||||
nyd = votesDown*ryf;
|
||||
nyu = int(votesUp*ryf);
|
||||
nyd = int(votesDown*ryf);
|
||||
}
|
||||
else
|
||||
{
|
||||
ryf = ((float)lv)/50.0f;
|
||||
nyu = votesUp/ryf;
|
||||
nyd = votesDown/ryf;
|
||||
nyu = int(votesUp/ryf);
|
||||
nyd = int(votesDown/ryf);
|
||||
}
|
||||
nyu = nyu>50?50:nyu;
|
||||
nyd = nyd>50?50:nyd;
|
||||
@ -325,8 +325,8 @@ void PreviewView::OnTick(float dt)
|
||||
{
|
||||
if(addCommentBox)
|
||||
{
|
||||
ui::Point positionDiff = ui::Point(commentBoxPositionX, commentBoxPositionY)-addCommentBox->Position;
|
||||
ui::Point sizeDiff = ui::Point(commentBoxSizeX, commentBoxSizeY)-addCommentBox->Size;
|
||||
ui::Point positionDiff = ui::Point(int(commentBoxPositionX), int(commentBoxPositionY))-addCommentBox->Position;
|
||||
ui::Point sizeDiff = ui::Point(int(commentBoxSizeX), int(commentBoxSizeY))-addCommentBox->Size;
|
||||
|
||||
if(positionDiff.X!=0)
|
||||
{
|
||||
@ -468,10 +468,10 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
|
||||
float factorX = ((float)XRES/2)/((float)savePreview->Width);
|
||||
float factorY = ((float)YRES/2)/((float)savePreview->Height);
|
||||
float scaleFactor = factorY < factorX ? factorY : factorX;
|
||||
savePreview->Buffer = Graphics::resample_img(oldData, savePreview->Width, savePreview->Height, savePreview->Width*scaleFactor, savePreview->Height*scaleFactor);
|
||||
savePreview->Buffer = Graphics::resample_img(oldData, savePreview->Width, savePreview->Height, int(savePreview->Width*scaleFactor), int(savePreview->Height*scaleFactor));
|
||||
delete[] oldData;
|
||||
savePreview->Width *= scaleFactor;
|
||||
savePreview->Height *= scaleFactor;
|
||||
savePreview->Width = int(savePreview->Width * scaleFactor);
|
||||
savePreview->Height = int(savePreview->Height * scaleFactor);
|
||||
}
|
||||
}
|
||||
else if (!sender->GetCanOpen())
|
||||
@ -527,8 +527,8 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
|
||||
if(sender->GetCommentBoxEnabled())
|
||||
{
|
||||
commentBoxPositionX = (XRES/2)+4;
|
||||
commentBoxPositionY = Size.Y-19;
|
||||
commentBoxSizeX = Size.X-(XRES/2)-48;
|
||||
commentBoxPositionY = float(Size.Y-19);
|
||||
commentBoxSizeX = float(Size.X-(XRES/2)-48);
|
||||
commentBoxSizeY = 17;
|
||||
|
||||
addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), "", "Add Comment");
|
||||
|
@ -259,7 +259,7 @@ void SearchController::removeSelectedC()
|
||||
c->Refresh();
|
||||
return false;
|
||||
}
|
||||
notifyProgress((float(i+1)/float(saves.size())*100));
|
||||
notifyProgress((i + 1) * 100 / saves.size());
|
||||
}
|
||||
c->Refresh();
|
||||
return true;
|
||||
@ -328,7 +328,7 @@ void SearchController::unpublishSelectedC(bool publish)
|
||||
c->Refresh();
|
||||
return false;
|
||||
}
|
||||
notifyProgress((float(i+1)/float(saves.size())*100));
|
||||
notifyProgress((i + 1) * 100 / saves.size());
|
||||
}
|
||||
c->Refresh();
|
||||
return true;
|
||||
@ -356,7 +356,7 @@ void SearchController::FavouriteSelected()
|
||||
notifyError(String::Build("Failed to favourite [", saves[i], "]: " + Client::Ref().GetLastError()));
|
||||
return false;
|
||||
}
|
||||
notifyProgress((float(i+1)/float(saves.size())*100));
|
||||
notifyProgress((i + 1) * 100 / saves.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -377,7 +377,7 @@ void SearchController::FavouriteSelected()
|
||||
notifyError(String::Build("Failed to unfavourite [", saves[i], "]: " + Client::Ref().GetLastError()));
|
||||
return false;
|
||||
}
|
||||
notifyProgress((float(i+1)/float(saves.size())*100));
|
||||
notifyProgress((i + 1) * 100 / saves.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
{
|
||||
int total, done;
|
||||
request->CheckProgress(&total, &done);
|
||||
notifyProgress((float(done)/float(total))*100.0f);
|
||||
notifyProgress(total ? done * 100 / total : 0);
|
||||
Platform::Millisleep(1);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ int luacon_partwrite(lua_State* l)
|
||||
*((float*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = luaL_optnumber(l, 3, 0);
|
||||
break;
|
||||
case CommandInterface::FormatElement:
|
||||
luacon_sim->part_change_type(i, luacon_sim->parts[i].x, luacon_sim->parts[i].y, luaL_optinteger(l, 3, 0));
|
||||
luacon_sim->part_change_type(i, int(luacon_sim->parts[i].x + 0.5f), int(luacon_sim->parts[i].y + 0.5f), luaL_optinteger(l, 3, 0));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -256,7 +256,7 @@ int luacon_elementwrite(lua_State* l)
|
||||
|
||||
if (prop.Name == "type") // i.e. it's .type
|
||||
{
|
||||
luacon_sim->part_change_type(i, luacon_sim->parts[i].x+0.5f, luacon_sim->parts[i].y+0.5f, luaL_checkinteger(l, 3));
|
||||
luacon_sim->part_change_type(i, int(luacon_sim->parts[i].x+0.5f), int(luacon_sim->parts[i].y+0.5f), luaL_checkinteger(l, 3));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -591,7 +591,7 @@ int luatpt_set_pressure(lua_State* l)
|
||||
y1 = abs(luaL_optint(l, 2, 0));
|
||||
width = abs(luaL_optint(l, 3, XRES/CELL));
|
||||
height = abs(luaL_optint(l, 4, YRES/CELL));
|
||||
value = (float)luaL_optint(l, 5, 0.0f);
|
||||
value = luaL_optnumber(l, 5, 0.0f);
|
||||
if(value > 256.0f)
|
||||
value = 256.0f;
|
||||
else if(value < -256.0f)
|
||||
@ -622,7 +622,7 @@ int luatpt_set_gravity(lua_State* l)
|
||||
y1 = abs(luaL_optint(l, 2, 0));
|
||||
width = abs(luaL_optint(l, 3, XRES/CELL));
|
||||
height = abs(luaL_optint(l, 4, YRES/CELL));
|
||||
value = (float)luaL_optint(l, 5, 0.0f);
|
||||
value = luaL_optnumber(l, 5, 0.0f);
|
||||
if(value > 256.0f)
|
||||
value = 256.0f;
|
||||
else if(value < -256.0f)
|
||||
@ -809,7 +809,7 @@ int luatpt_set_property(lua_State* l)
|
||||
return 0;
|
||||
|
||||
if (format == CommandInterface::FormatElement)
|
||||
luacon_sim->part_change_type(i, luacon_sim->parts[i].x, luacon_sim->parts[i].y, t);
|
||||
luacon_sim->part_change_type(i, int(luacon_sim->parts[i].x + 0.5f), int(luacon_sim->parts[i].y + 0.5f), t);
|
||||
else if (format == CommandInterface::FormatFloat)
|
||||
*((float*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = f;
|
||||
else
|
||||
@ -875,14 +875,14 @@ int luatpt_set_elecmap(lua_State* l)
|
||||
{
|
||||
int nx, ny, acount;
|
||||
int x1, y1, width, height;
|
||||
float value;
|
||||
unsigned char value;
|
||||
acount = lua_gettop(l);
|
||||
|
||||
x1 = abs(luaL_optint(l, 1, 0));
|
||||
y1 = abs(luaL_optint(l, 2, 0));
|
||||
width = abs(luaL_optint(l, 3, XRES/CELL));
|
||||
height = abs(luaL_optint(l, 4, YRES/CELL));
|
||||
value = (float)luaL_optint(l, acount, 0);
|
||||
value = luaL_optint(l, acount, 0);
|
||||
|
||||
if(acount==5) //Draw rect
|
||||
{
|
||||
@ -1369,10 +1369,10 @@ int luatpt_setfpscap(lua_State* l)
|
||||
int acount = lua_gettop(l);
|
||||
if (acount == 0)
|
||||
{
|
||||
lua_pushinteger(l, ui::Engine::Ref().FpsLimit);
|
||||
lua_pushnumber(l, ui::Engine::Ref().FpsLimit);
|
||||
return 1;
|
||||
}
|
||||
int fpscap = luaL_checkint(l, 1);
|
||||
float fpscap = luaL_checknumber(l, 1);
|
||||
if (fpscap < 2)
|
||||
return luaL_error(l, "fps cap too small");
|
||||
ui::Engine::Ref().FpsLimit = fpscap;
|
||||
|
@ -65,6 +65,14 @@ extern "C"
|
||||
#include "socket.lua.h"
|
||||
#include "eventcompat.lua.h"
|
||||
|
||||
// idea from mniip, makes things much simpler
|
||||
#define SETCONST(L, NAME)\
|
||||
lua_pushinteger(L, NAME);\
|
||||
lua_setfield(L, -2, #NAME)
|
||||
#define SETCONSTF(L, NAME)\
|
||||
lua_pushnumber(L, NAME);\
|
||||
lua_setfield(L, -2, #NAME)
|
||||
|
||||
GameModel * luacon_model;
|
||||
GameController * luacon_controller;
|
||||
Simulation * luacon_sim;
|
||||
@ -733,7 +741,7 @@ int LuaScriptInterface::simulation_newsign(lua_State *l)
|
||||
|
||||
luacon_sim->signs.push_back(sign(text, x, y, (sign::Justification)ju));
|
||||
|
||||
lua_pushnumber(l, luacon_sim->signs.size());
|
||||
lua_pushinteger(l, luacon_sim->signs.size());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -829,8 +837,8 @@ void LuaScriptInterface::initSimulationAPI()
|
||||
SETCONST(l, ST);
|
||||
SETCONST(l, ITH);
|
||||
SETCONST(l, ITL);
|
||||
SETCONST(l, IPH);
|
||||
SETCONST(l, IPL);
|
||||
SETCONSTF(l, IPH);
|
||||
SETCONSTF(l, IPL);
|
||||
SETCONST(l, PT_NUM);
|
||||
lua_pushinteger(l, 0); lua_setfield(l, -2, "NUM_PARTS");
|
||||
SETCONST(l, R_TEMP);
|
||||
@ -964,7 +972,7 @@ int LuaScriptInterface::simulation_partChangeType(lua_State * l)
|
||||
int partIndex = lua_tointeger(l, 1);
|
||||
if(partIndex < 0 || partIndex >= NPART || !luacon_sim->parts[partIndex].type)
|
||||
return 0;
|
||||
luacon_sim->part_change_type(partIndex, luacon_sim->parts[partIndex].x+0.5f, luacon_sim->parts[partIndex].y+0.5f, lua_tointeger(l, 2));
|
||||
luacon_sim->part_change_type(partIndex, int(luacon_sim->parts[partIndex].x+0.5f), int(luacon_sim->parts[partIndex].y+0.5f), lua_tointeger(l, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1092,7 +1100,7 @@ int LuaScriptInterface::simulation_partProperty(lua_State * l)
|
||||
{
|
||||
if (prop == properties.begin() + 0) // i.e. it's .type
|
||||
{
|
||||
luacon_sim->part_change_type(particleID, luacon_sim->parts[particleID].x+0.5f, luacon_sim->parts[particleID].y+0.5f, luaL_checkinteger(l, 3));
|
||||
luacon_sim->part_change_type(particleID, int(luacon_sim->parts[particleID].x+0.5f), int(luacon_sim->parts[particleID].y+0.5f), luaL_checkinteger(l, 3));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -33,11 +33,6 @@ class Tool;
|
||||
#define LUACON_EL_MODIFIED_GRAPHICS 0x2
|
||||
#define LUACON_EL_MODIFIED_MENUS 0x4
|
||||
|
||||
// idea from mniip, makes things much simpler
|
||||
#define SETCONST(L, NAME)\
|
||||
lua_pushinteger(L, NAME);\
|
||||
lua_setfield(L, -2, #NAME)
|
||||
|
||||
class Simulation;
|
||||
class TPTScriptInterface;
|
||||
class LuaComponent;
|
||||
|
@ -26,7 +26,7 @@ AnyType::operator NumberType()
|
||||
if (type == TypeNumber)
|
||||
return NumberType(value.num);
|
||||
else if (type == TypeFloat)
|
||||
return NumberType(value.numf);
|
||||
return NumberType(int(value.numf));
|
||||
else
|
||||
throw InvalidConversionException(type, TypeNumber);
|
||||
}
|
||||
@ -34,7 +34,7 @@ AnyType::operator NumberType()
|
||||
AnyType::operator FloatType()
|
||||
{
|
||||
if (type == TypeNumber)
|
||||
return FloatType(value.num);
|
||||
return FloatType(float(value.num));
|
||||
else if (type == TypeFloat)
|
||||
return FloatType(value.numf);
|
||||
else
|
||||
|
@ -273,11 +273,11 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
|
||||
float newValuef = 0.0f;
|
||||
if (value.GetType() == TypeNumber)
|
||||
{
|
||||
newValuef = newValue = ((NumberType)value).Value();
|
||||
newValuef = float(newValue = ((NumberType)value).Value());
|
||||
}
|
||||
else if (value.GetType() == TypeFloat)
|
||||
{
|
||||
newValue = newValuef = ((FloatType)value).Value();
|
||||
newValue = int(newValuef = ((FloatType)value).Value());
|
||||
}
|
||||
else if(value.GetType() == TypeString)
|
||||
{
|
||||
@ -332,7 +332,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
|
||||
*((float*)(partsBlock+(partIndex*sizeof(Particle))+propertyOffset)) = newValuef;
|
||||
break;
|
||||
case FormatElement:
|
||||
sim->part_change_type(partIndex, sim->parts[partIndex].x, sim->parts[partIndex].y, newValue);
|
||||
sim->part_change_type(partIndex, int(sim->parts[partIndex].x + 0.5f), int(sim->parts[partIndex].y + 0.5f), newValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -369,7 +369,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
|
||||
if (sim->parts[j].type)
|
||||
{
|
||||
returnValue++;
|
||||
sim->part_change_type(j, sim->parts[j].x, sim->parts[j].y, newValue);
|
||||
sim->part_change_type(j, int(sim->parts[j].x + 0.5f), int(sim->parts[j].y + 0.5f), newValue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -417,7 +417,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
|
||||
if (sim->parts[j].type == type)
|
||||
{
|
||||
returnValue++;
|
||||
sim->part_change_type(j, sim->parts[j].x, sim->parts[j].y, newValue);
|
||||
sim->part_change_type(j, int(sim->parts[j].x + 0.5f), int(sim->parts[j].y + 0.5f), newValue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -523,7 +523,7 @@ AnyType TPTScriptInterface::tptS_bubble(std::deque<String> * words)
|
||||
|
||||
for (int i = 1; i<=30; i++)
|
||||
{
|
||||
rem2 = sim->create_part(-1, bubblePos.X+18*cosf(i/5.0), bubblePos.Y+18*sinf(i/5.0), PT_SOAP);
|
||||
rem2 = sim->create_part(-1, int(bubblePos.X+18*cosf(i/5.0)+0.5f), int(bubblePos.Y+18*sinf(i/5.0)+0.5f), PT_SOAP);
|
||||
|
||||
sim->parts[rem1].ctype = 7;
|
||||
sim->parts[rem1].tmp = rem2;
|
||||
|
@ -242,18 +242,18 @@ void Air::update_air(void)
|
||||
// Trying to take velocity from far away, check whether there is an intervening wall. Step from current position to desired source location, looking for walls, with either the x or y step size being 1 cell
|
||||
if (std::abs(dx)>std::abs(dy))
|
||||
{
|
||||
stepX = (dx<0.0f) ? 1 : -1;
|
||||
stepX = (dx<0.0f) ? 1.f : -1.f;
|
||||
stepY = -dy/fabsf(dx);
|
||||
stepLimit = (int)(fabsf(dx*advDistanceMult));
|
||||
}
|
||||
else
|
||||
{
|
||||
stepY = (dy<0.0f) ? 1 : -1;
|
||||
stepY = (dy<0.0f) ? 1.f : -1.f;
|
||||
stepX = -dx/fabsf(dy);
|
||||
stepLimit = (int)(fabsf(dy*advDistanceMult));
|
||||
}
|
||||
tx = x;
|
||||
ty = y;
|
||||
tx = float(x);
|
||||
ty = float(y);
|
||||
for (step=0; step<stepLimit; ++step)
|
||||
{
|
||||
tx += stepX;
|
||||
|
@ -87,7 +87,7 @@ void Gravity::grav_fft_init()
|
||||
plan_gravy_inverse = fftwf_plan_dft_c2r_2d(yblock2, xblock2, th_gravybigt, th_gravybig, FFTW_MEASURE);
|
||||
|
||||
//(XRES/CELL)*(YRES/CELL)*4 is size of data array, scaling needed because FFTW calculates an unnormalized DFT
|
||||
scaleFactor = -M_GRAV/((XRES/CELL)*(YRES/CELL)*4);
|
||||
scaleFactor = -float(M_GRAV)/((XRES/CELL)*(YRES/CELL)*4);
|
||||
//calculate velocity map caused by a point mass
|
||||
for (int y = 0; y < yblock2; y++)
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ std::pair<int, sign::Type> sign::split()
|
||||
return std::make_pair(0, Type::Normal);
|
||||
}
|
||||
}
|
||||
return std::make_pair(pipe, text[1] == 'c' ? Type::Save : Type::Thread);
|
||||
return std::make_pair(int(pipe), text[1] == 'c' ? Type::Save : Type::Thread);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -174,7 +174,7 @@ std::pair<int, sign::Type> sign::split()
|
||||
case 's':
|
||||
if (text[2] == ':' && (pipe = text.find('|', 3)) != text.npos)
|
||||
{
|
||||
return std::make_pair(pipe, Type::Search);
|
||||
return std::make_pair(int(pipe), Type::Search);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -903,8 +903,8 @@ bool Simulation::flood_water(int x, int y, int i)
|
||||
int oldy = (int)(parts[i].y + 0.5f);
|
||||
pmap[y - 1][x] = pmap[oldy][oldx];
|
||||
pmap[oldy][oldx] = 0;
|
||||
parts[i].x = x;
|
||||
parts[i].y = y - 1;
|
||||
parts[i].x = float(x);
|
||||
parts[i].y = float(y - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -991,7 +991,7 @@ void Simulation::SetEdgeMode(int newEdgeMode)
|
||||
void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_, int colA_, int mode)
|
||||
{
|
||||
int rp;
|
||||
float tr, tg, tb, ta, colR = colR_, colG = colG_, colB = colB_, colA = colA_;
|
||||
float tr, tg, tb, ta, colR = float(colR_), colG = float(colG_), colB = float(colB_), colA = float(colA_);
|
||||
float strength = 0.01f;
|
||||
rp = pmap[y][x];
|
||||
if (!rp)
|
||||
@ -999,10 +999,10 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_,
|
||||
if (!rp)
|
||||
return;
|
||||
|
||||
ta = (parts[ID(rp)].dcolour>>24)&0xFF;
|
||||
tr = (parts[ID(rp)].dcolour>>16)&0xFF;
|
||||
tg = (parts[ID(rp)].dcolour>>8)&0xFF;
|
||||
tb = (parts[ID(rp)].dcolour)&0xFF;
|
||||
ta = float((parts[ID(rp)].dcolour>>24)&0xFF);
|
||||
tr = float((parts[ID(rp)].dcolour>>16)&0xFF);
|
||||
tg = float((parts[ID(rp)].dcolour>>8)&0xFF);
|
||||
tb = float((parts[ID(rp)].dcolour)&0xFF);
|
||||
|
||||
ta /= 255.0f; tr /= 255.0f; tg /= 255.0f; tb /= 255.0f;
|
||||
colR /= 255.0f; colG /= 255.0f; colB /= 255.0f; colA /= 255.0f;
|
||||
@ -1135,10 +1135,10 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_,
|
||||
ta *= 255.0f; tr *= 255.0f; tg *= 255.0f; tb *= 255.0f;
|
||||
ta += .5f; tr += .5f; tg += .5f; tb += .5f;
|
||||
|
||||
colA_ = ta;
|
||||
colR_ = tr;
|
||||
colG_ = tg;
|
||||
colB_ = tb;
|
||||
colA_ = int(ta);
|
||||
colR_ = int(tr);
|
||||
colG_ = int(tg);
|
||||
colB_ = int(tb);
|
||||
|
||||
if(colA_ > 255)
|
||||
colA_ = 255;
|
||||
@ -2226,8 +2226,8 @@ void Simulation::create_arc(int sx, int sy, int dx, int dy, int midpoints, int v
|
||||
|
||||
for(i = 1; i <= midpoints; i++)
|
||||
{
|
||||
ymid[i] = ymid[i-1]+yint;
|
||||
xmid[i] = xmid[i-1]+xint;
|
||||
ymid[i] = ymid[i-1]+int(yint);
|
||||
xmid[i] = xmid[i-1]+int(xint);
|
||||
}
|
||||
|
||||
for(i = 0; i <= midpoints; i++)
|
||||
@ -2692,7 +2692,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
if (parts[ID(r)].life == 0)
|
||||
{
|
||||
part_change_type(i, x, y, PT_GRVT);
|
||||
parts[i].tmp = parts[ID(r)].temp - 273.15f;
|
||||
parts[i].tmp = int(parts[ID(r)].temp - 273.15f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2811,21 +2811,21 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
if (s)
|
||||
{
|
||||
pmap[ny][nx] = (s&~PMAPMASK)|parts[ID(s)].type;
|
||||
parts[ID(s)].x = nx;
|
||||
parts[ID(s)].y = ny;
|
||||
parts[ID(s)].x = float(nx);
|
||||
parts[ID(s)].y = float(ny);
|
||||
}
|
||||
else
|
||||
pmap[ny][nx] = 0;
|
||||
parts[ri].x = x;
|
||||
parts[ri].y = y;
|
||||
parts[ri].x = float(x);
|
||||
parts[ri].y = float(y);
|
||||
pmap[y][x] = PMAP(ri, parts[ri].type);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ID(pmap[ny][nx]) == ri)
|
||||
pmap[ny][nx] = 0;
|
||||
parts[ri].x += x-nx;
|
||||
parts[ri].y += y-ny;
|
||||
parts[ri].x += float(x-nx);
|
||||
parts[ri].y += float(y-ny);
|
||||
pmap[(int)(parts[ri].y+0.5f)][(int)(parts[ri].x+0.5f)] = PMAP(ri, parts[ri].type);
|
||||
}
|
||||
return 1;
|
||||
@ -3016,8 +3016,8 @@ int Simulation::get_normal(int pt, int x, int y, float dx, float dy, float *nx,
|
||||
if ((lx == rx) && (ly == ry))
|
||||
return 0;
|
||||
|
||||
ex = rx - lx;
|
||||
ey = ry - ly;
|
||||
ex = float(rx - lx);
|
||||
ey = float(ry - ly);
|
||||
r = 1.0f/hypot(ex, ey);
|
||||
*nx = ey * r;
|
||||
*ny = -ex * r;
|
||||
@ -3246,9 +3246,9 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
if((elements[t].Properties & TYPE_PART) && pretty_powder)
|
||||
{
|
||||
int colr, colg, colb;
|
||||
colr = PIXR(elements[t].Colour) + sandcolour * 1.3 + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colg = PIXG(elements[t].Colour) + sandcolour * 1.3 + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colb = PIXB(elements[t].Colour) + sandcolour * 1.3 + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colr = PIXR(elements[t].Colour) + int(sandcolour * 1.3) + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colg = PIXG(elements[t].Colour) + int(sandcolour * 1.3) + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colb = PIXB(elements[t].Colour) + int(sandcolour * 1.3) + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colr = colr>255 ? 255 : (colr<0 ? 0 : colr);
|
||||
colg = colg>255 ? 255 : (colg<0 ? 0 : colg);
|
||||
colb = colb>255 ? 255 : (colb<0 ? 0 : colb);
|
||||
@ -3281,7 +3281,7 @@ void Simulation::GetGravityField(int x, int y, float particleGrav, float newtonG
|
||||
case 2: //radial gravity
|
||||
if (x-XCNTR != 0 || y-YCNTR != 0)
|
||||
{
|
||||
float pGravMult = particleGrav/sqrtf((x-XCNTR)*(x-XCNTR) + (y-YCNTR)*(y-YCNTR));
|
||||
float pGravMult = particleGrav/sqrtf(float((x-XCNTR)*(x-XCNTR) + (y-YCNTR)*(y-YCNTR)));
|
||||
pGravX -= pGravMult * (float)(x - XCNTR);
|
||||
pGravY -= pGravMult * (float)(y - YCNTR);
|
||||
}
|
||||
@ -3499,7 +3499,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
pGravX = pGravY = 0.0f;
|
||||
break;
|
||||
case 2:
|
||||
pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
|
||||
pGravD = 0.01f - hypotf(float(x - XCNTR), float(y - YCNTR));
|
||||
pGravX = elements[t].Gravity * ((float)(x - XCNTR) / pGravD);
|
||||
pGravY = elements[t].Gravity * ((float)(y - YCNTR) / pGravD);
|
||||
break;
|
||||
@ -3573,7 +3573,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
#ifdef REALISTIC
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale))
|
||||
#else
|
||||
if (t && (t!=PT_HSWC||parts[i].life==10) && RNG::Ref().chance(elements[t].HeatConduct*gel_scale, 250))
|
||||
if (t && (t!=PT_HSWC||parts[i].life==10) && RNG::Ref().chance(int(elements[t].HeatConduct*gel_scale), 250))
|
||||
#endif
|
||||
{
|
||||
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
||||
@ -3908,7 +3908,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP);
|
||||
if (t == PT_LAVA)
|
||||
{
|
||||
parts[i].life = restrict_flt((parts[i].temp-700)/7, 0.0f, 400.0f);
|
||||
parts[i].life = int(restrict_flt((parts[i].temp-700)/7, 0, 400));
|
||||
if (parts[i].ctype==PT_THRM&&parts[i].tmp>0)
|
||||
{
|
||||
parts[i].tmp--;
|
||||
@ -4315,8 +4315,8 @@ killed:
|
||||
parts[ID(r)].ctype = parts[i].type;
|
||||
parts[ID(r)].temp = parts[i].temp;
|
||||
parts[ID(r)].tmp2 = parts[i].life;
|
||||
parts[ID(r)].pavg[0] = parts[i].tmp;
|
||||
parts[ID(r)].pavg[1] = parts[i].ctype;
|
||||
parts[ID(r)].pavg[0] = float(parts[i].tmp);
|
||||
parts[ID(r)].pavg[1] = float(parts[i].ctype);
|
||||
kill_part(i);
|
||||
continue;
|
||||
}
|
||||
@ -4453,7 +4453,7 @@ killed:
|
||||
rt = 10;
|
||||
|
||||
if (t==PT_GEL)
|
||||
rt = parts[i].tmp*0.20f+5.0f;
|
||||
rt = int(parts[i].tmp*0.20f+5.0f);
|
||||
|
||||
for (j=clear_x+r; j>=0 && j>=clear_x-rt && j<clear_x+rt && j<XRES; j+=r)
|
||||
{
|
||||
@ -4521,7 +4521,7 @@ killed:
|
||||
pGravX = pGravY = 0.0f;
|
||||
break;
|
||||
case 2:
|
||||
pGravD = 0.01f - hypotf((nx - XCNTR), (ny - YCNTR));
|
||||
pGravD = 0.01f - hypotf(float(nx - XCNTR), float(ny - YCNTR));
|
||||
pGravX = ptGrav * ((float)(nx - XCNTR) / pGravD);
|
||||
pGravY = ptGrav * ((float)(ny - YCNTR) / pGravD);
|
||||
break;
|
||||
@ -4593,7 +4593,7 @@ killed:
|
||||
pGravX = pGravY = 0.0f;
|
||||
break;
|
||||
case 2:
|
||||
pGravD = 0.01f - hypotf((nx - XCNTR), (ny - YCNTR));
|
||||
pGravD = 0.01f - hypotf(float(nx - XCNTR), float(ny - YCNTR));
|
||||
pGravX = ptGrav * ((float)(nx - XCNTR) / pGravD);
|
||||
pGravY = ptGrav * ((float)(ny - YCNTR) / pGravD);
|
||||
break;
|
||||
|
@ -53,7 +53,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
float multiplier;
|
||||
if (parts[i].life!=0)
|
||||
{
|
||||
float change = parts[i].life > 1000 ? 1000 : (parts[i].life < 0 ? 0 : parts[i].life);
|
||||
auto change = parts[i].life > 1000 ? 1000 : (parts[i].life < 0 ? 0 : parts[i].life);
|
||||
multiplier = 1.0f+(change/100.0f);
|
||||
}
|
||||
else
|
||||
|
@ -79,7 +79,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
}
|
||||
else if (rt != PT_CLNE && rt != PT_PCLN && parts[i].life >= 50 && RNG::Ref().chance(sim->elements[rt].Hardness, 1000.0))
|
||||
else if (rt != PT_CLNE && rt != PT_PCLN && parts[i].life >= 50 && RNG::Ref().chance(sim->elements[rt].Hardness, 1000))
|
||||
{
|
||||
if (sim->parts_avg(i, ID(r),PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid
|
||||
{
|
||||
|
@ -150,8 +150,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
parts[np].temp = parts[r].temp;
|
||||
parts[np].life = parts[r].tmp2;
|
||||
parts[np].tmp = parts[r].pavg[0];
|
||||
parts[np].ctype = parts[r].pavg[1];
|
||||
parts[np].tmp = int(parts[r].pavg[0]);
|
||||
parts[np].ctype = int(parts[r].pavg[1]);
|
||||
parts[r].tmp = 0;
|
||||
parts[r].life = 10;
|
||||
break;
|
||||
|
@ -108,8 +108,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[i].tmp = 0;
|
||||
parts[i].life = 50;
|
||||
parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP);
|
||||
parts[i].vx = RNG::Ref().between(-10, 10);
|
||||
parts[i].vy = RNG::Ref().between(-10, 10);
|
||||
parts[i].vx = float(RNG::Ref().between(-10, 10));
|
||||
parts[i].vy = float(RNG::Ref().between(-10, 10));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -65,20 +65,20 @@ int Element_BIZR_update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)!=PT_BIZR && TYP(r)!=PT_BIZRG && TYP(r)!=PT_BIZRS)
|
||||
{
|
||||
tr = (parts[ID(r)].dcolour>>16)&0xFF;
|
||||
tg = (parts[ID(r)].dcolour>>8)&0xFF;
|
||||
tb = (parts[ID(r)].dcolour)&0xFF;
|
||||
ta = (parts[ID(r)].dcolour>>24)&0xFF;
|
||||
tr = float((parts[ID(r)].dcolour>>16)&0xFF);
|
||||
tg = float((parts[ID(r)].dcolour>>8)&0xFF);
|
||||
tb = float((parts[ID(r)].dcolour)&0xFF);
|
||||
ta = float((parts[ID(r)].dcolour>>24)&0xFF);
|
||||
|
||||
mr = (parts[i].dcolour>>16)&0xFF;
|
||||
mg = (parts[i].dcolour>>8)&0xFF;
|
||||
mb = (parts[i].dcolour)&0xFF;
|
||||
ma = (parts[i].dcolour>>24)&0xFF;
|
||||
mr = float((parts[i].dcolour>>16)&0xFF);
|
||||
mg = float((parts[i].dcolour>>8)&0xFF);
|
||||
mb = float((parts[i].dcolour)&0xFF);
|
||||
ma = float((parts[i].dcolour>>24)&0xFF);
|
||||
|
||||
nr = (tr*BLEND) + (mr*(1 - BLEND));
|
||||
ng = (tg*BLEND) + (mg*(1 - BLEND));
|
||||
nb = (tb*BLEND) + (mb*(1 - BLEND));
|
||||
na = (ta*BLEND) + (ma*(1 - BLEND));
|
||||
nr = int((tr*BLEND) + (mr*(1 - BLEND)));
|
||||
ng = int((tg*BLEND) + (mg*(1 - BLEND)));
|
||||
nb = int((tb*BLEND) + (mb*(1 - BLEND)));
|
||||
na = int((ta*BLEND) + (ma*(1 - BLEND)));
|
||||
|
||||
parts[ID(r)].dcolour = nr<<16 | ng<<8 | nb | na<<24;
|
||||
}
|
||||
@ -113,9 +113,9 @@ int Element_BIZR_graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
brightness /= 5;
|
||||
*firea = 255;
|
||||
*fireg = *colg * brightness;
|
||||
*fireb = *colb * brightness;
|
||||
*firer = *colr * brightness;
|
||||
*fireg = int(*colg * brightness);
|
||||
*fireb = int(*colb * brightness);
|
||||
*firer = int(*colr * brightness);
|
||||
*pixel_mode |= FIRE_ADD;
|
||||
}
|
||||
*pixel_mode |= PMODE_BLUR;
|
||||
|
@ -99,8 +99,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 50;
|
||||
parts[nb].temp = MAX_TEMP;
|
||||
parts[nb].vx = RNG::Ref().between(-20, 20);
|
||||
parts[nb].vy = RNG::Ref().between(-20, 20);
|
||||
parts[nb].vx = float(RNG::Ref().between(-20, 20));
|
||||
parts[nb].vy = float(RNG::Ref().between(-20, 20));
|
||||
}
|
||||
}
|
||||
sim->kill_part(i);
|
||||
|
@ -50,7 +50,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int r, rx, ry, tempFactor;
|
||||
if (parts[i].temp > 523.15f)//250.0f+273.15f
|
||||
{
|
||||
tempFactor = 1000 - ((523.15f-parts[i].temp)*2);
|
||||
tempFactor = int(1000 - ((523.15f-parts[i].temp)*2));
|
||||
if(tempFactor < 2)
|
||||
tempFactor = 2;
|
||||
for (rx=-1; rx<2; rx++)
|
||||
|
@ -91,7 +91,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
//Start explode
|
||||
parts[i].tmp = RNG::Ref().between(0, 24);
|
||||
}
|
||||
else if((sim->elements[TYP(r)].Properties&TYPE_SOLID) && TYP(r)!=PT_DMND && TYP(r)!=PT_GLAS && parts[i].tmp == 0 && RNG::Ref().chance(2 - sim->pv[y/CELL][x/CELL], 6667))
|
||||
else if((sim->elements[TYP(r)].Properties&TYPE_SOLID) && TYP(r)!=PT_DMND && TYP(r)!=PT_GLAS && parts[i].tmp == 0 && RNG::Ref().chance(int(2 - sim->pv[y/CELL][x/CELL]), 6667))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CO2);
|
||||
parts[i].ctype = 5;
|
||||
|
@ -51,7 +51,7 @@ void Element::Element_CFLM()
|
||||
|
||||
static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
|
||||
int caddress = int(restrict_flt(float(cpart->life / 2), 0, 199)) * 3;
|
||||
*colr = hflm_data[caddress];
|
||||
*colg = hflm_data[caddress+1];
|
||||
*colb = hflm_data[caddress+2];
|
||||
|
@ -76,13 +76,13 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
else if (TYP(r)==PT_CLST)
|
||||
{
|
||||
if(parts[i].temp <195)
|
||||
cxy = 0.05;
|
||||
cxy = 0.05f;
|
||||
else if(parts[i].temp <295)
|
||||
cxy = 0.015;
|
||||
cxy = 0.015f;
|
||||
else if(parts[i].temp <350)
|
||||
cxy = 0.01;
|
||||
cxy = 0.01f;
|
||||
else
|
||||
cxy = 0.005;
|
||||
cxy = 0.005f;
|
||||
parts[i].vx += cxy*rx;
|
||||
parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005.
|
||||
}
|
||||
|
@ -72,16 +72,16 @@ int Element_COAL_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
if(parts[i].temp > parts[i].tmp2)
|
||||
parts[i].tmp2 = parts[i].temp;
|
||||
parts[i].tmp2 = int(parts[i].temp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
constexpr float FREQUENCY = 3.1415/(2*300.0f-(300.0f-200.0f));
|
||||
constexpr float FREQUENCY = 3.1415f/(2*300.0f-(300.0f-200.0f));
|
||||
|
||||
int Element_COAL_graphics(GRAPHICS_FUNC_ARGS)
|
||||
//Both COAL and Broken Coal
|
||||
{
|
||||
*colr += (cpart->tmp2-295.15f)/3;
|
||||
*colr += int((cpart->tmp2-295.15f)/3);
|
||||
|
||||
if (*colr > 170)
|
||||
*colr = 170;
|
||||
@ -94,11 +94,11 @@ int Element_COAL_graphics(GRAPHICS_FUNC_ARGS)
|
||||
if (cpart->temp > 395.15f)
|
||||
{
|
||||
// q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f);
|
||||
int q = (cpart->temp > 595.15f) ? 200.0f : cpart->temp - 395.15f;
|
||||
auto q = int((cpart->temp > 595.15f) ? 200.0f : cpart->temp - 395.15f);
|
||||
|
||||
*colr += sin(FREQUENCY*q) * 226;
|
||||
*colg += sin(FREQUENCY*q*4.55 + 3.14) * 34;
|
||||
*colb += sin(FREQUENCY*q*2.22 + 3.14) * 64;
|
||||
*colr += int(sin(FREQUENCY*q) * 226);
|
||||
*colg += int(sin(FREQUENCY*q*4.55 + 3.14) * 34);
|
||||
*colb += int(sin(FREQUENCY*q*2.22 + 3.14) * 64);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -57,12 +57,12 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
float gravtot = fabs(sim->gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(sim->gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]);
|
||||
// Prevent division by 0
|
||||
float temp = std::max(1.0f, (parts[i].temp + 1));
|
||||
int maxlife = ((10000/(temp + 1))-1);
|
||||
auto maxlife = int(((10000/(temp + 1))-1));
|
||||
if (RNG::Ref().chance(10000 % static_cast<int>(temp + 1), static_cast<int>(temp + 1)))
|
||||
maxlife++;
|
||||
// Compress when Newtonian gravity is applied
|
||||
// multiplier=1 when gravtot=0, multiplier -> 5 as gravtot -> inf
|
||||
maxlife = maxlife*(5.0f - 8.0f/(gravtot+2.0f));
|
||||
maxlife = maxlife*int(5.0f - 8.0f/(gravtot+2.0f));
|
||||
if (parts[i].life < maxlife)
|
||||
{
|
||||
for (rx=-1; rx<2; rx++)
|
||||
|
@ -68,7 +68,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
for (nxi=-rad; nxi<=rad; nxi++)
|
||||
if (x+nxi>=0 && y+nxj>=0 && x+nxi<XRES && y+nxj<YRES && (nxi || nxj))
|
||||
{
|
||||
dist = sqrt(pow(nxi, 2.0f)+pow(nxj, 2.0f));//;(pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2));
|
||||
dist = int(sqrt(pow(nxi, 2.0f)+pow(nxj, 2.0f)));//;(pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2));
|
||||
if (!dist || (dist <= rad))
|
||||
{
|
||||
rr = pmap[y+nxj][x+nxi];
|
||||
|
@ -162,8 +162,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[p] = parts[ID(sim->photons[yCurrent][xCurrent])];
|
||||
else
|
||||
parts[p] = parts[ID(pmap[yCurrent][xCurrent])];
|
||||
parts[p].x = xCopyTo;
|
||||
parts[p].y = yCopyTo;
|
||||
parts[p].x = float(xCopyTo);
|
||||
parts[p].y = float(yCopyTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 50;
|
||||
parts[nb].temp = parts[i].temp*0.8f;
|
||||
parts[nb].vx = RNG::Ref().between(-10, 10);
|
||||
parts[nb].vy = RNG::Ref().between(-10, 10);
|
||||
parts[nb].vx = float(RNG::Ref().between(-10, 10));
|
||||
parts[nb].vy = float(RNG::Ref().between(-10, 10));
|
||||
}
|
||||
}
|
||||
sim->kill_part(i);
|
||||
|
@ -84,9 +84,9 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
if (maxComponent<60)//make sure it isn't too dark to see
|
||||
{
|
||||
float multiplier = 60.0f/maxComponent;
|
||||
*colr *= multiplier;
|
||||
*colg *= multiplier;
|
||||
*colb *= multiplier;
|
||||
*colr = int(*colr * multiplier);
|
||||
*colg = int(*colg * multiplier);
|
||||
*colb = int(*colb * multiplier);
|
||||
}
|
||||
}
|
||||
else if (cpart->tmp != 0)
|
||||
|
@ -108,8 +108,8 @@ void Element_EMP_Trigger(Simulation *sim, int triggerCount)
|
||||
for (int r = 0; r <=sim->parts_lastActiveIndex; r++)
|
||||
{
|
||||
int t = parts[r].type;
|
||||
int rx = parts[r].x;
|
||||
int ry = parts[r].y;
|
||||
auto rx = int(parts[r].x);
|
||||
auto ry = int(parts[r].y);
|
||||
if (t==PT_SPRK || (t==PT_SWCH && parts[r].life!=0 && parts[r].life!=10) || (t==PT_WIRE && parts[r].ctype>0))
|
||||
{
|
||||
bool is_elec = false;
|
||||
@ -165,7 +165,7 @@ void Element_EMP_Trigger(Simulation *sim, int triggerCount)
|
||||
if (RNG::Ref().uniform01() < prob_randWIFI)
|
||||
{
|
||||
// Randomize channel
|
||||
parts[n].temp = RNG::Ref().between(0, MAX_TEMP-1);
|
||||
parts[n].temp = float(RNG::Ref().between(0, MAX_TEMP-1));
|
||||
}
|
||||
if (RNG::Ref().uniform01() < prob_breakWIFI)
|
||||
{
|
||||
@ -210,8 +210,8 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
if(cpart->life)
|
||||
{
|
||||
*colr = cpart->life*1.5;
|
||||
*colg = cpart->life*1.5;
|
||||
*colr = int(cpart->life*1.5);
|
||||
*colg = int(cpart->life*1.5);
|
||||
*colb = 200-(cpart->life);
|
||||
}
|
||||
return 0;
|
||||
|
@ -102,7 +102,7 @@ int Element_ETRD_nearestSparkablePart(Simulation *sim, int targetId)
|
||||
Particle *parts = sim->parts;
|
||||
int foundDistance = XRES + YRES;
|
||||
int foundI = -1;
|
||||
ui::Point targetPos = ui::Point(parts[targetId].x, parts[targetId].y);
|
||||
ui::Point targetPos = ui::Point(int(parts[targetId].x), int(parts[targetId].y));
|
||||
|
||||
if (sim->etrd_count_valid)
|
||||
{
|
||||
@ -141,7 +141,7 @@ int Element_ETRD_nearestSparkablePart(Simulation *sim, int targetId)
|
||||
{
|
||||
if (parts[i].type == PT_ETRD && !parts[i].life)
|
||||
{
|
||||
ui::Point checkPos = ui::Point(parts[i].x-targetPos.X, parts[i].y-targetPos.Y);
|
||||
ui::Point checkPos = ui::Point(int(parts[i].x)-targetPos.X, int(parts[i].y)-targetPos.Y);
|
||||
int checkDistance = std::abs(checkPos.X) + std::abs(checkPos.Y);
|
||||
if (checkDistance < foundDistance && i != targetId)
|
||||
{
|
||||
@ -161,7 +161,7 @@ int Element_ETRD_nearestSparkablePart(Simulation *sim, int targetId)
|
||||
if (parts[i].type == PT_ETRD && !parts[i].life)
|
||||
{
|
||||
countLife0++;
|
||||
ui::Point checkPos = ui::Point(parts[i].x-targetPos.X, parts[i].y-targetPos.Y);
|
||||
ui::Point checkPos = ui::Point(int(parts[i].x)-targetPos.X, int(parts[i].y)-targetPos.Y);
|
||||
int checkDistance = std::abs(checkPos.X) + std::abs(checkPos.Y);
|
||||
if (checkDistance < foundDistance && i != targetId)
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
sim->pv[y/CELL][x/CELL] -= 0.01;
|
||||
sim->pv[y/CELL][x/CELL] -= 0.01f;
|
||||
parts[i].tmp--;
|
||||
}
|
||||
return 0;
|
||||
@ -184,17 +184,17 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
|
||||
static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int q = cpart->temp;
|
||||
int b = cpart->tmp;
|
||||
int c = cpart->tmp2;
|
||||
auto q = cpart->temp;
|
||||
auto b = cpart->tmp;
|
||||
auto c = cpart->tmp2;
|
||||
if (cpart->life < 1001)
|
||||
{
|
||||
if (RNG::Ref().chance(cpart->tmp2 - 1, 1000))
|
||||
{
|
||||
float frequency = 0.04045;
|
||||
*colr = (sin(frequency*c + 4) * 127 + 150);
|
||||
*colg = (sin(frequency*c + 6) * 127 + 150);
|
||||
*colb = (sin(frequency*c + 8) * 127 + 150);
|
||||
float frequency = 0.04045f;
|
||||
*colr = int(sin(frequency*c + 4) * 127 + 150);
|
||||
*colg = int(sin(frequency*c + 6) * 127 + 150);
|
||||
*colb = int(sin(frequency*c + 8) * 127 + 150);
|
||||
|
||||
*firea = 100;
|
||||
*firer = 0;
|
||||
@ -206,10 +206,10 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
float frequency = 0.00045;
|
||||
*colr = (sin(frequency*q + 4) * 127 + (b/1.7));
|
||||
*colg = (sin(frequency*q + 6) * 127 + (b/1.7));
|
||||
*colb = (sin(frequency*q + 8) * 127 + (b/1.7));
|
||||
float frequency = 0.00045f;
|
||||
*colr = int(sin(frequency*q + 4) * 127 + (b/1.7));
|
||||
*colg = int(sin(frequency*q + 6) * 127 + (b/1.7));
|
||||
*colb = int(sin(frequency*q + 8) * 127 + (b/1.7));
|
||||
*cola = cpart->tmp / 6;
|
||||
|
||||
*firea = *cola;
|
||||
@ -223,10 +223,10 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
float frequency = 0.01300;
|
||||
*colr = (sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80));
|
||||
*colg = (sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80));
|
||||
*colb = (sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80));
|
||||
float frequency = 0.01300f;
|
||||
*colr = int(sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80));
|
||||
*colg = int(sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80));
|
||||
*colb = int(sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80));
|
||||
*cola = cpart->tmp / 6;
|
||||
*firea = *cola;
|
||||
*firer = *colr;
|
||||
|
@ -109,8 +109,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (tarx<x)
|
||||
{
|
||||
if(figh->rocketBoots || !(sim->eval_move(PT_FIGH, figh->legs[4]-10, figh->legs[5]+6, NULL)
|
||||
&& sim->eval_move(PT_FIGH, figh->legs[4]-10, figh->legs[5]+3, NULL)))
|
||||
if(figh->rocketBoots || !(sim->eval_move(PT_FIGH, int(figh->legs[4])-10, int(figh->legs[5])+6, NULL)
|
||||
&& sim->eval_move(PT_FIGH, int(figh->legs[4])-10, int(figh->legs[5])+3, NULL)))
|
||||
figh->comm = 0x01;
|
||||
else
|
||||
figh->comm = 0x02;
|
||||
@ -120,15 +120,15 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (tary<y)
|
||||
figh->comm = (int)figh->comm | 0x04;
|
||||
}
|
||||
else if (!sim->eval_move(PT_FIGH, figh->legs[4]-4, figh->legs[5]-1, NULL)
|
||||
|| !sim->eval_move(PT_FIGH, figh->legs[12]-4, figh->legs[13]-1, NULL)
|
||||
|| sim->eval_move(PT_FIGH, 2*figh->legs[4]-figh->legs[6], figh->legs[5]+5, NULL))
|
||||
else if (!sim->eval_move(PT_FIGH, int(figh->legs[4])-4, int(figh->legs[5])-1, NULL)
|
||||
|| !sim->eval_move(PT_FIGH, int(figh->legs[12])-4, int(figh->legs[13])-1, NULL)
|
||||
|| sim->eval_move(PT_FIGH, 2*int(figh->legs[4])-int(figh->legs[6]), int(figh->legs[5])+5, NULL))
|
||||
figh->comm = (int)figh->comm | 0x04;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (figh->rocketBoots || !(sim->eval_move(PT_FIGH, figh->legs[12]+10, figh->legs[13]+6, NULL)
|
||||
&& sim->eval_move(PT_FIGH, figh->legs[12]+10, figh->legs[13]+3, NULL)))
|
||||
if (figh->rocketBoots || !(sim->eval_move(PT_FIGH, int(figh->legs[12])+10, int(figh->legs[13])+6, NULL)
|
||||
&& sim->eval_move(PT_FIGH, int(figh->legs[12])+10, int(figh->legs[13])+3, NULL)))
|
||||
figh->comm = 0x02;
|
||||
else
|
||||
figh->comm = 0x01;
|
||||
@ -138,9 +138,9 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (tary<y)
|
||||
figh->comm = (int)figh->comm | 0x04;
|
||||
}
|
||||
else if (!sim->eval_move(PT_FIGH, figh->legs[4]+4, figh->legs[5]-1, NULL)
|
||||
|| !sim->eval_move(PT_FIGH, figh->legs[4]+4, figh->legs[5]-1, NULL)
|
||||
|| sim->eval_move(PT_FIGH, 2*figh->legs[12]-figh->legs[14], figh->legs[13]+5, NULL))
|
||||
else if (!sim->eval_move(PT_FIGH, int(figh->legs[4])+4, int(figh->legs[5])-1, NULL)
|
||||
|| !sim->eval_move(PT_FIGH, int(figh->legs[4])+4, int(figh->legs[5])-1, NULL)
|
||||
|| sim->eval_move(PT_FIGH, 2*int(figh->legs[12])-int(figh->legs[14]), int(figh->legs[13])+5, NULL))
|
||||
figh->comm = (int)figh->comm | 0x04;
|
||||
}
|
||||
break;
|
||||
|
@ -256,7 +256,7 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
|
||||
if ((surround_space || sim->elements[rt].Explosive) &&
|
||||
sim->elements[rt].Flammable && RNG::Ref().chance(sim->elements[rt].Flammable + (sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f), 1000) &&
|
||||
sim->elements[rt].Flammable && RNG::Ref().chance(int(sim->elements[rt].Flammable + (sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f)), 1000) &&
|
||||
//exceptions, t is the thing causing the spark and rt is what's burning
|
||||
(t != PT_SPRK || (rt != PT_RBDM && rt != PT_LRBD && rt != PT_INSL)) &&
|
||||
(t != PT_PHOT || rt != PT_INSL) &&
|
||||
@ -350,7 +350,7 @@ static int updateLegacy(UPDATE_FUNC_ARGS)
|
||||
|
||||
static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
|
||||
int caddress = int(restrict_flt(float(cpart->life), 0, 199)) * 3;
|
||||
*colr = (unsigned char)ren->flm_data[caddress];
|
||||
*colg = (unsigned char)ren->flm_data[caddress+1];
|
||||
*colb = (unsigned char)ren->flm_data[caddress+2];
|
||||
|
@ -104,7 +104,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[np].ctype = col;
|
||||
parts[np].tmp = 1;
|
||||
parts[np].life = RNG::Ref().between(70, 109);
|
||||
parts[np].temp = RNG::Ref().between(5750, 6249);
|
||||
parts[np].temp = float(RNG::Ref().between(5750, 6249));
|
||||
parts[np].dcolour = parts[i].dcolour;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ void Element::Element_FRZZ()
|
||||
HighPressureTransition = PT_SNOW;
|
||||
LowTemperature = 50.0f;
|
||||
LowTemperatureTransition = PT_ICEI;
|
||||
HighTemperature = 273.15;
|
||||
HighTemperature = 273.15f;
|
||||
HighTemperatureTransition = PT_FRZW;
|
||||
|
||||
Update = &update;
|
||||
|
@ -48,7 +48,7 @@ void Element::Element_FWRK()
|
||||
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && RNG::Ref().chance(9+parts[i].temp/40, 100000)) || parts[i].ctype == PT_DUST))
|
||||
if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && RNG::Ref().chance(int(9+parts[i].temp/40), 100000)) || parts[i].ctype == PT_DUST))
|
||||
{
|
||||
float gx, gy, multiplier, gmax;
|
||||
int randTmp;
|
||||
@ -100,7 +100,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[np].ctype = col;
|
||||
parts[np].tmp = 1;
|
||||
parts[np].life = RNG::Ref().between(70, 109);
|
||||
parts[np].temp = RNG::Ref().between(5750, 6249);
|
||||
parts[np].temp = float(RNG::Ref().between(5750, 6249));
|
||||
parts[np].dcolour = parts[i].dcolour;
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
nd = dx*dx + dy*dy - 0.5;
|
||||
per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5);
|
||||
if (sim->elements[rt].Properties&TYPE_LIQUID)
|
||||
per *= 0.1;
|
||||
per *= 0.1f;
|
||||
dx *= per; dy *= per;
|
||||
parts[i].vx += dx;
|
||||
parts[i].vy += dy;
|
||||
|
@ -66,7 +66,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
parts[i].ctype = sim->pv[y/CELL][x/CELL]*16;
|
||||
parts[i].ctype = int(sim->pv[y/CELL][x/CELL]*16);
|
||||
parts[i].tmp = abs((int)((sim->vx[y/CELL][x/CELL]+sim->vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f));
|
||||
|
||||
return 0;
|
||||
@ -74,13 +74,13 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
|
||||
static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
*firer = restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f;
|
||||
*fireg = restrict_flt(cpart->ctype, 0, 128)/50.0f;
|
||||
*fireb = restrict_flt(cpart->tmp, 0, 128)/50.0f;
|
||||
*firer = int(restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f);
|
||||
*fireg = int(restrict_flt(float(cpart->ctype), 0, 128)/50.0f);
|
||||
*fireb = int(restrict_flt(float(cpart->tmp), 0, 128)/50.0f);
|
||||
|
||||
*colr = restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255);
|
||||
*colg = restrict_flt(64.0f+cpart->ctype, 0, 255);
|
||||
*colb = restrict_flt(64.0f+cpart->tmp, 0, 255);
|
||||
*colr = int(restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255));
|
||||
*colg = int(restrict_flt(64.0f+cpart->ctype, 0, 255));
|
||||
*colb = int(restrict_flt(64.0f+cpart->tmp, 0, 255));
|
||||
|
||||
*pixel_mode |= FIRE_ADD;
|
||||
return 0;
|
||||
|
@ -59,10 +59,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parts[i].temp>=256.0+273.15)
|
||||
parts[i].temp=256.0+273.15;
|
||||
if (parts[i].temp<= -256.0+273.15)
|
||||
parts[i].temp = -256.0+273.15;
|
||||
if (parts[i].temp>=256.0f+273.15f)
|
||||
parts[i].temp=256.0f+273.15f;
|
||||
if (parts[i].temp<= -256.0f+273.15f)
|
||||
parts[i].temp = -256.0f+273.15f;
|
||||
|
||||
sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 0.2f*(parts[i].temp-273.15);
|
||||
for (rx=-2; rx<3; rx++)
|
||||
|
@ -76,29 +76,29 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
*colb = 20;
|
||||
if (cpart->vx>0)
|
||||
{
|
||||
*colr += (cpart->vx)*GRAV_R;
|
||||
*colg += (cpart->vx)*GRAV_G;
|
||||
*colb += (cpart->vx)*GRAV_B;
|
||||
*colr += int((cpart->vx)*GRAV_R);
|
||||
*colg += int((cpart->vx)*GRAV_G);
|
||||
*colb += int((cpart->vx)*GRAV_B);
|
||||
}
|
||||
if (cpart->vy>0)
|
||||
{
|
||||
*colr += (cpart->vy)*GRAV_G;
|
||||
*colg += (cpart->vy)*GRAV_B;
|
||||
*colb += (cpart->vy)*GRAV_R;
|
||||
*colr += int((cpart->vy)*GRAV_G);
|
||||
*colg += int((cpart->vy)*GRAV_B);
|
||||
*colb += int((cpart->vy)*GRAV_R);
|
||||
|
||||
}
|
||||
if (cpart->vx<0)
|
||||
{
|
||||
*colr -= (cpart->vx)*GRAV_B;
|
||||
*colg -= (cpart->vx)*GRAV_R;
|
||||
*colb -= (cpart->vx)*GRAV_G;
|
||||
*colr -= int((cpart->vx)*GRAV_B);
|
||||
*colg -= int((cpart->vx)*GRAV_R);
|
||||
*colb -= int((cpart->vx)*GRAV_G);
|
||||
|
||||
}
|
||||
if (cpart->vy<0)
|
||||
{
|
||||
*colr -= (cpart->vy)*GRAV_R2;
|
||||
*colg -= (cpart->vy)*GRAV_G2;
|
||||
*colb -= (cpart->vy)*GRAV_B2;
|
||||
*colr -= int((cpart->vy)*GRAV_R2);
|
||||
*colg -= int((cpart->vy)*GRAV_G2);
|
||||
*colb -= int((cpart->vy)*GRAV_B2);
|
||||
}
|
||||
|
||||
if (cpart->life)
|
||||
|
@ -80,7 +80,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int newTemp = parts[ID(r)].ctype - 0x10000000;
|
||||
if (newTemp >= MIN_TEMP && newTemp <= MAX_TEMP)
|
||||
parts[i].temp = parts[ID(r)].ctype - 0x10000000;
|
||||
parts[i].temp = float(parts[ID(r)].ctype - 0x10000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (nb!=-1) {
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 30;
|
||||
parts[nb].vx = RNG::Ref().between(-10, 10);
|
||||
parts[nb].vy = RNG::Ref().between(-10, 10);
|
||||
parts[nb].vx = float(RNG::Ref().between(-10, 10));
|
||||
parts[nb].vy = float(RNG::Ref().between(-10, 10));
|
||||
parts[nb].temp = restrict_flt(parts[i].temp-273.15f+400.0f, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ void Element::Element_ISOZ()
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
float rr, rrr;
|
||||
if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(-4.0f * sim->pv[y/CELL][x/CELL], 1000))
|
||||
if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(int(-4.0f * sim->pv[y/CELL][x/CELL]), 1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PHOT);
|
||||
rr = RNG::Ref().between(128, 355) / 127.0f;
|
||||
|
@ -49,7 +49,7 @@ void Element::Element_ISZS()
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
float rr, rrr;
|
||||
if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(-4.0f * sim->pv[y/CELL][x/CELL], 1000))
|
||||
if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(int(-4.0f * sim->pv[y/CELL][x/CELL]), 1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PHOT);
|
||||
rr = RNG::Ref().between(128, 355) / 127.0f;
|
||||
|
@ -80,9 +80,9 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
else
|
||||
{
|
||||
auto mul = (cpart->tmp2 - 1) / float(states - 2);
|
||||
*colr = PIXR(colour1) * mul + PIXR(colour2) * (1.f - mul);
|
||||
*colg = PIXG(colour1) * mul + PIXG(colour2) * (1.f - mul);
|
||||
*colb = PIXB(colour1) * mul + PIXB(colour2) * (1.f - mul);
|
||||
*colr = int(PIXR(colour1) * mul + PIXR(colour2) * (1.f - mul));
|
||||
*colg = int(PIXG(colour1) * mul + PIXG(colour2) * (1.f - mul));
|
||||
*colb = int(PIXB(colour1) * mul + PIXB(colour2) * (1.f - mul));
|
||||
}
|
||||
}
|
||||
*pixel_mode |= NO_DECO;
|
||||
|
@ -3,7 +3,7 @@
|
||||
static int update(UPDATE_FUNC_ARGS);
|
||||
static int graphics(GRAPHICS_FUNC_ARGS);
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS);
|
||||
static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2);
|
||||
static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, float temp, int life, int tmp, int tmp2);
|
||||
|
||||
void Element::Element_LIGH()
|
||||
{
|
||||
@ -71,7 +71,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
*/
|
||||
int r,rx,ry,rt, multipler, powderful;
|
||||
float angle, angle2=-1;
|
||||
powderful = parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER;
|
||||
powderful = int(parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER);
|
||||
//Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
|
||||
if (sim->aheat_enable)
|
||||
{
|
||||
@ -93,7 +93,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
rt = TYP(r);
|
||||
if ((surround_space || sim->elements[rt].Explosive) &&
|
||||
(rt!=PT_SPNG || parts[ID(r)].life==0) &&
|
||||
sim->elements[rt].Flammable && RNG::Ref().chance(sim->elements[rt].Flammable + sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f, 1000))
|
||||
sim->elements[rt].Flammable && RNG::Ref().chance(sim->elements[rt].Flammable + int(sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f), 1000))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE);
|
||||
parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].DefaultProperties.temp + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP);
|
||||
@ -121,8 +121,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_NEUT);
|
||||
parts[ID(r)].life = RNG::Ref().between(480, 959);
|
||||
parts[ID(r)].vx = RNG::Ref().between(-5, 5);
|
||||
parts[ID(r)].vy = RNG::Ref().between(-5, 5);
|
||||
parts[ID(r)].vx = float(RNG::Ref().between(-5, 5));
|
||||
parts[ID(r)].vy = float(RNG::Ref().between(-5, 5));
|
||||
}
|
||||
break;
|
||||
case PT_COAL:
|
||||
@ -172,29 +172,29 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
return 1;
|
||||
}
|
||||
|
||||
angle = (parts[i].tmp + RNG::Ref().between(-30, 30)) % 360;
|
||||
multipler = parts[i].life * 1.5 + RNG::Ref().between(0, parts[i].life);
|
||||
rx=cos(angle*M_PI/180)*multipler;
|
||||
ry=-sin(angle*M_PI/180)*multipler;
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle, parts[i].tmp2);
|
||||
angle = float((parts[i].tmp + RNG::Ref().between(-30, 30)) % 360);
|
||||
multipler = int(parts[i].life * 1.5) + RNG::Ref().between(0, parts[i].life);
|
||||
rx=int(cos(angle*M_PI/180)*multipler);
|
||||
ry=int(-sin(angle*M_PI/180)*multipler);
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, int(angle), parts[i].tmp2);
|
||||
if (parts[i].tmp2==2)// && pNear==-1)
|
||||
{
|
||||
angle2 = ((int)angle + RNG::Ref().between(-100, 100)) % 360;
|
||||
rx=cos(angle2*M_PI/180)*multipler;
|
||||
ry=-sin(angle2*M_PI/180)*multipler;
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle2, parts[i].tmp2);
|
||||
angle2 = float(((int)angle + RNG::Ref().between(-100, 100)) % 360);
|
||||
rx=int(cos(angle2*M_PI/180)*multipler);
|
||||
ry=int(-sin(angle2*M_PI/180)*multipler);
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, int(angle2), parts[i].tmp2);
|
||||
}
|
||||
|
||||
parts[i].tmp2=-1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2, bool last)
|
||||
static bool create_LIGH(Simulation * sim, int x, int y, int c, float temp, int life, int tmp, int tmp2, bool last)
|
||||
{
|
||||
int p = sim->create_part(-1, x, y,c);
|
||||
if (p != -1)
|
||||
{
|
||||
sim->parts[p].temp = temp;
|
||||
sim->parts[p].temp = float(temp);
|
||||
sim->parts[p].tmp = tmp;
|
||||
if (last)
|
||||
{
|
||||
@ -217,7 +217,7 @@ static bool create_LIGH(Simulation * sim, int x, int y, int c, int temp, int lif
|
||||
return false;
|
||||
}
|
||||
|
||||
static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2)
|
||||
static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, float temp, int life, int tmp, int tmp2)
|
||||
{
|
||||
bool reverseXY = abs(y2-y1) > abs(x2-x1), back = false;
|
||||
int x, y, dx, dy, Ystep;
|
||||
|
@ -55,8 +55,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
// Obscure division by 0 fix
|
||||
if (parts[i].temp + 1 == 0)
|
||||
parts[i].temp = 0;
|
||||
int maxtmp = (absorbScale/(parts[i].temp + 1))-1;
|
||||
if (RNG::Ref().chance(absorbScale%((int)parts[i].temp+1), parts[i].temp+1))
|
||||
int maxtmp = int(absorbScale/(parts[i].temp + 1))-1;
|
||||
if (RNG::Ref().chance(absorbScale%(int(parts[i].temp)+1), int(parts[i].temp)+1))
|
||||
maxtmp ++;
|
||||
|
||||
if (parts[i].tmp < 0)
|
||||
|
@ -68,8 +68,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DSTW);
|
||||
case PT_ICEI:
|
||||
case PT_SNOW:
|
||||
parts[i].vx *= 0.995;
|
||||
parts[i].vy *= 0.995;
|
||||
parts[i].vx *= 0.995f;
|
||||
parts[i].vy *= 0.995f;
|
||||
break;
|
||||
case PT_PLUT:
|
||||
if (RNG::Ref().chance(pressureFactor, 1000))
|
||||
|
@ -120,8 +120,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int r = sim->create_part(-1, x + rx, y + ry, PT_PHOT);
|
||||
if (r != -1)
|
||||
{
|
||||
parts[r].vx = rx * 3;
|
||||
parts[r].vy = ry * 3;
|
||||
parts[r].vx = float(rx * 3);
|
||||
parts[r].vy = float(ry * 3);
|
||||
if (r>i)
|
||||
{
|
||||
// Make sure movement doesn't happen until next frame, to avoid gaps in the beams of photons produced
|
||||
|
@ -111,8 +111,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int r = sim->create_part(-1, x + rx, y + ry, PT_PHOT);
|
||||
if (r != -1)
|
||||
{
|
||||
parts[r].vx = rx * 3;
|
||||
parts[r].vy = ry * 3;
|
||||
parts[r].vx = float(rx * 3);
|
||||
parts[r].vy = float(ry * 3);
|
||||
if (r>i)
|
||||
{
|
||||
// Make sure movement doesn't happen until next frame, to avoid gaps in the beams of photons produced
|
||||
|
@ -75,8 +75,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 400))
|
||||
{
|
||||
parts[i].vx *= 0.90;
|
||||
parts[i].vy *= 0.90;
|
||||
parts[i].vx *= 0.90f;
|
||||
parts[i].vy *= 0.90f;
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
|
||||
rrr = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
if (TYP(r) == PT_ISOZ)
|
||||
|
@ -355,8 +355,8 @@ int Element_PIPE_graphics(GRAPHICS_FUNC_ARGS)
|
||||
tpart.type = t;
|
||||
tpart.temp = cpart->temp;
|
||||
tpart.life = cpart->tmp2;
|
||||
tpart.tmp = cpart->pavg[0];
|
||||
tpart.ctype = cpart->pavg[1];
|
||||
tpart.tmp = int(cpart->pavg[0]);
|
||||
tpart.ctype = int(cpart->pavg[1]);
|
||||
if (t == PT_PHOT && tpart.ctype == 0x40000000)
|
||||
tpart.ctype = 0x3FFFFFFF;
|
||||
|
||||
@ -418,8 +418,8 @@ void Element_PIPE_transfer_pipe_to_part(Simulation * sim, Particle *pipe, Partic
|
||||
}
|
||||
part->temp = pipe->temp;
|
||||
part->life = pipe->tmp2;
|
||||
part->tmp = pipe->pavg[0];
|
||||
part->ctype = pipe->pavg[1];
|
||||
part->tmp = int(pipe->pavg[0]);
|
||||
part->ctype = int(pipe->pavg[1]);
|
||||
|
||||
if (!(sim->elements[part->type].Properties & TYPE_ENERGY))
|
||||
{
|
||||
@ -438,8 +438,8 @@ static void transfer_part_to_pipe(Particle *part, Particle *pipe)
|
||||
pipe->ctype = part->type;
|
||||
pipe->temp = part->temp;
|
||||
pipe->tmp2 = part->life;
|
||||
pipe->pavg[0] = part->tmp;
|
||||
pipe->pavg[1] = part->ctype;
|
||||
pipe->pavg[0] = float(part->tmp);
|
||||
pipe->pavg[1] = float(part->ctype);
|
||||
}
|
||||
|
||||
static void transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR)
|
||||
|
@ -52,7 +52,7 @@ void Element::Element_PLSM()
|
||||
|
||||
static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
|
||||
int caddress = int(restrict_flt(float(cpart->life), 0, 199)) * 3;
|
||||
*colr = (unsigned char)ren->plasma_data[caddress];
|
||||
*colg = (unsigned char)ren->plasma_data[caddress+1];
|
||||
*colb = (unsigned char)ren->plasma_data[caddress+2];
|
||||
|
@ -49,7 +49,7 @@ void Element::Element_PLUT()
|
||||
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 100) && RNG::Ref().chance(5.0f*sim->pv[y/CELL][x/CELL], 1000))
|
||||
if (RNG::Ref().chance(1, 100) && RNG::Ref().chance(int(5.0f*sim->pv[y/CELL][x/CELL]), 1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_NEUT);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].temp > 273.15f + 500.0f && (sim->elements[utype].Flammable || sim->elements[utype].Explosive || utype == PT_BANG))
|
||||
{
|
||||
sim->create_part(uID, x, y, PT_FIRE);
|
||||
parts[uID].temp += restrict_flt(sim->elements[utype].Flammable * 5, MIN_TEMP, MAX_TEMP);
|
||||
parts[uID].temp += restrict_flt(float(sim->elements[utype].Flammable * 5), MIN_TEMP, MAX_TEMP);
|
||||
sim->pv[y / CELL][x / CELL] += 1.00f;
|
||||
}
|
||||
//prevent inactive sparkable elements from being sparked
|
||||
|
@ -130,8 +130,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
|
||||
parts[np].x = x+rx;
|
||||
parts[np].y = y+ry;
|
||||
parts[np].x = float(x+rx);
|
||||
parts[np].y = float(y+ry);
|
||||
memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
|
||||
break;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
ny = y + ry;
|
||||
while (TYP(r) == PT_FILT)
|
||||
{
|
||||
parts[ID(r)].ctype = 0x10000000 + roundl(photonWl) + 256;
|
||||
parts[ID(r)].ctype = 0x10000000 + int(round(photonWl)) + 256;
|
||||
nx += rx;
|
||||
ny += ry;
|
||||
if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES)
|
||||
|
@ -136,14 +136,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
pistonCount += floor((parts[ID(r)].temp-268.15)/10);// How many tens of degrees above 0 C, rounded to nearest ten degrees. Can be negative.
|
||||
pistonCount += int(floor((parts[ID(r)].temp-268.15f)/10));// How many tens of degrees above 0 C, rounded to nearest ten degrees. Can be negative.
|
||||
}
|
||||
}
|
||||
else if (nxx==0 && nyy==0)
|
||||
{
|
||||
// compatibility with BAD THINGS: starting PSTN layered underneath other particles
|
||||
// (in v90, it started scanning from the neighbouring particle, so could not break out of loop at offset=(0,0))
|
||||
pistonCount += floor((parts[i].temp-268.15)/10);
|
||||
pistonCount += int(floor((parts[i].temp-268.15f)/10));
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@ -305,8 +305,8 @@ static int MoveStack(Simulation * sim, int stackX, int stackY, int directionX, i
|
||||
int srcX = (int)(sim->parts[jP].x + 0.5f), srcY = (int)(sim->parts[jP].y + 0.5f);
|
||||
int destX = srcX-directionX*amount, destY = srcY-directionY*amount;
|
||||
sim->pmap[srcY][srcX] = 0;
|
||||
sim->parts[jP].x = destX;
|
||||
sim->parts[jP].y = destY;
|
||||
sim->parts[jP].x = float(destX);
|
||||
sim->parts[jP].y = float(destY);
|
||||
sim->pmap[destY][destX] = PMAP(jP, sim->parts[jP].type);
|
||||
}
|
||||
return amount;
|
||||
@ -328,8 +328,8 @@ static int MoveStack(Simulation * sim, int stackX, int stackY, int directionX, i
|
||||
int srcX = (int)(sim->parts[jP].x + 0.5f), srcY = (int)(sim->parts[jP].y + 0.5f);
|
||||
int destX = srcX+directionX*possibleMovement, destY = srcY+directionY*possibleMovement;
|
||||
sim->pmap[srcY][srcX] = 0;
|
||||
sim->parts[jP].x = destX;
|
||||
sim->parts[jP].y = destY;
|
||||
sim->parts[jP].x = float(destX);
|
||||
sim->parts[jP].y = float(destY);
|
||||
sim->pmap[destY][destX] = PMAP(jP, sim->parts[jP].type);
|
||||
}
|
||||
return possibleMovement;
|
||||
|
@ -60,10 +60,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parts[i].temp >= 256.0+273.15)
|
||||
parts[i].temp = 256.0+273.15;
|
||||
if (parts[i].temp <= -256.0+273.15)
|
||||
parts[i].temp = -256.0+273.15;
|
||||
if (parts[i].temp >= 256.0f+273.15f)
|
||||
parts[i].temp = 256.0f+273.15f;
|
||||
if (parts[i].temp <= -256.0f+273.15f)
|
||||
parts[i].temp = -256.0f+273.15f;
|
||||
|
||||
for (rx = -1; rx <= 1; rx++)
|
||||
for (ry = -1; ry <= 1; ry++)
|
||||
@ -81,7 +81,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int newPressure = parts[ID(r)].ctype - 0x10000000;
|
||||
if (newPressure >= 0 && newPressure <= 512)
|
||||
{
|
||||
sim->pv[(y + ry) / CELL][(x + rx) / CELL] = newPressure - 256;
|
||||
sim->pv[(y + ry) / CELL][(x + rx) / CELL] = float(newPressure - 256);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
*pixel_mode |= FIRE_ADD;
|
||||
|
||||
*firea = ((cpart->temp)-810.15)/45;
|
||||
*firea = int(((cpart->temp)-810.15)/45);
|
||||
*firer = *colr;
|
||||
*fireg = *colg;
|
||||
*fireb = *colb;
|
||||
|
@ -77,7 +77,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
spawncount = std::abs(parts[i].tmp);
|
||||
spawncount = (spawncount>255) ? 3019 : std::pow((double)(spawncount/8), 2)*M_PI;
|
||||
spawncount = (spawncount>255) ? 3019 : int(std::pow((double)(spawncount/8), 2)*M_PI);
|
||||
for (int j = 0;j < spawncount; j++)
|
||||
{
|
||||
switch (RNG::Ref().gen() % 3)
|
||||
|
@ -260,14 +260,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)!=PT_SOAP)
|
||||
{
|
||||
tr = (parts[ID(r)].dcolour>>16)&0xFF;
|
||||
tg = (parts[ID(r)].dcolour>>8)&0xFF;
|
||||
tb = (parts[ID(r)].dcolour)&0xFF;
|
||||
ta = (parts[ID(r)].dcolour>>24)&0xFF;
|
||||
nr = (tr*BLEND);
|
||||
ng = (tg*BLEND);
|
||||
nb = (tb*BLEND);
|
||||
na = (ta*BLEND);
|
||||
tr = float((parts[ID(r)].dcolour>>16)&0xFF);
|
||||
tg = float((parts[ID(r)].dcolour>>8)&0xFF);
|
||||
tb = float((parts[ID(r)].dcolour)&0xFF);
|
||||
ta = float((parts[ID(r)].dcolour>>24)&0xFF);
|
||||
nr = int(tr*BLEND);
|
||||
ng = int(tg*BLEND);
|
||||
nb = int(tb*BLEND);
|
||||
na = int(ta*BLEND);
|
||||
parts[ID(r)].dcolour = nr<<16 | ng<<8 | nb | na<<24;
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[i].life=60;
|
||||
parts[p].temp=parts[p].life*parts[i].tmp/2.5;
|
||||
parts[p].tmp2=1;
|
||||
parts[p].tmp=atan2(-ry, (float)rx)/M_PI*360;
|
||||
parts[p].tmp=int(atan2(-ry, (float)rx)/M_PI*360);
|
||||
parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling
|
||||
if (fabs(sim->pv[y/CELL][x/CELL])!=0.0f)
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
int r, rx, ry;
|
||||
int t = parts[i].type;
|
||||
float pp, d;
|
||||
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
|
||||
float dt = 0.9f;///(FPSB*FPSB); //Delta time in square
|
||||
float gvx, gvy;
|
||||
float gx, gy, dl, dr;
|
||||
float rocketBootsHeadEffect = 0.35f;
|
||||
@ -243,7 +243,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
bool moved = false;
|
||||
if (dl>dr)
|
||||
{
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL))
|
||||
{
|
||||
playerp->accs[2] = -3*gvy-3*gvx;
|
||||
playerp->accs[3] = 3*gvx-3*gvy;
|
||||
@ -254,7 +254,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL))
|
||||
{
|
||||
playerp->accs[6] = -3*gvy-3*gvx;
|
||||
playerp->accs[7] = 3*gvx-3*gvy;
|
||||
@ -275,7 +275,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (leg==1 && (((int)(playerp->comm)&0x02) == 0x02))
|
||||
continue;
|
||||
int footX = playerp->legs[leg*8+4], footY = playerp->legs[leg*8+5];
|
||||
int footX = int(playerp->legs[leg*8+4]), footY = int(playerp->legs[leg*8+5]);
|
||||
int np = sim->create_part(-1, footX, footY, PT_PLSM);
|
||||
if (np>=0)
|
||||
{
|
||||
@ -293,7 +293,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
bool moved = false;
|
||||
if (dl<dr)
|
||||
{
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL))
|
||||
{
|
||||
playerp->accs[2] = 3*gvy-3*gvx;
|
||||
playerp->accs[3] = -3*gvx-3*gvy;
|
||||
@ -304,7 +304,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL))
|
||||
{
|
||||
playerp->accs[6] = 3*gvy-3*gvx;
|
||||
playerp->accs[7] = -3*gvx-3*gvy;
|
||||
@ -325,7 +325,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (leg==0 && (((int)(playerp->comm)&0x01) == 0x01))
|
||||
continue;
|
||||
int footX = playerp->legs[leg*8+4], footY = playerp->legs[leg*8+5];
|
||||
int footX = int(playerp->legs[leg*8+4]), footY = int(playerp->legs[leg*8+5]);
|
||||
int np = sim->create_part(-1, footX, footY, PT_PLSM);
|
||||
if (np>=0)
|
||||
{
|
||||
@ -360,7 +360,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
playerp->accs[7] -= rocketBootsFeetEffectV*rby;
|
||||
for (int leg=0; leg<2; leg++)
|
||||
{
|
||||
int footX = playerp->legs[leg*8+4], footY = playerp->legs[leg*8+5];
|
||||
int footX = int(playerp->legs[leg*8+4]), footY = int(playerp->legs[leg*8+5]);
|
||||
int np = sim->create_part(-1, footX, footY+1, PT_PLSM);
|
||||
if (np>=0)
|
||||
{
|
||||
@ -370,8 +370,8 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) ||
|
||||
(INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL)))
|
||||
else if ((INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL)) ||
|
||||
(INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL)))
|
||||
{
|
||||
parts[i].vx -= 4*gvx;
|
||||
parts[i].vy -= 4*gvy;
|
||||
@ -415,7 +415,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
if (TYP(r) == PT_NEUT)
|
||||
{
|
||||
if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2;
|
||||
else parts[i].life *= 0.9f;
|
||||
else parts[i].life = int(parts[i].life * 0.9f);
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN)
|
||||
@ -482,17 +482,17 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
{
|
||||
parts[np].vy = 0;
|
||||
if (((int)playerp->pcomm)&(0x01|0x02))
|
||||
parts[np].vx = (((((int)playerp->pcomm)&0x02) == 0x02) - (((int)(playerp->pcomm)&0x01) == 0x01))*random;
|
||||
parts[np].vx = float((((((int)playerp->pcomm)&0x02) == 0x02) - (((int)(playerp->pcomm)&0x01) == 0x01))*random);
|
||||
else
|
||||
parts[np].vx = random;
|
||||
parts[np].vx = float(random);
|
||||
}
|
||||
}
|
||||
else if (playerp->elem == PT_LIGH)
|
||||
{
|
||||
float angle;
|
||||
int angle;
|
||||
int power = 100;
|
||||
if (gvx!=0 || gvy!=0)
|
||||
angle = atan2(gvx, gvy)*180.0f/M_PI;
|
||||
angle = int(atan2(gvx, gvy)*180.0f/M_PI);
|
||||
else
|
||||
angle = RNG::Ref().between(0, 359);
|
||||
if (((int)playerp->pcomm)&0x01)
|
||||
@ -543,27 +543,27 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
playerp->legs[8] += (playerp->legs[8]-parts[i].x)*d;
|
||||
playerp->legs[9] += (playerp->legs[9]-parts[i].y)*d;
|
||||
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL))
|
||||
{
|
||||
playerp->legs[4] = playerp->legs[6];
|
||||
playerp->legs[5] = playerp->legs[7];
|
||||
}
|
||||
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL))
|
||||
{
|
||||
playerp->legs[12] = playerp->legs[14];
|
||||
playerp->legs[13] = playerp->legs[15];
|
||||
}
|
||||
|
||||
//This makes stick man "pop" from obstacles
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
|
||||
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL))
|
||||
{
|
||||
float t;
|
||||
t = playerp->legs[4]; playerp->legs[4] = playerp->legs[6]; playerp->legs[6] = t;
|
||||
t = playerp->legs[5]; playerp->legs[5] = playerp->legs[7]; playerp->legs[7] = t;
|
||||
}
|
||||
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
|
||||
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL))
|
||||
{
|
||||
float t;
|
||||
t = playerp->legs[12]; playerp->legs[12] = playerp->legs[14]; playerp->legs[14] = t;
|
||||
@ -688,25 +688,25 @@ void Element_STKM_init_legs(Simulation * sim, playerst *playerp, int i)
|
||||
x = (int)(sim->parts[i].x+0.5f);
|
||||
y = (int)(sim->parts[i].y+0.5f);
|
||||
|
||||
playerp->legs[0] = x-1;
|
||||
playerp->legs[1] = y+6;
|
||||
playerp->legs[2] = x-1;
|
||||
playerp->legs[3] = y+6;
|
||||
playerp->legs[0] = float(x-1);
|
||||
playerp->legs[1] = float(y+6);
|
||||
playerp->legs[2] = float(x-1);
|
||||
playerp->legs[3] = float(y+6);
|
||||
|
||||
playerp->legs[4] = x-3;
|
||||
playerp->legs[5] = y+12;
|
||||
playerp->legs[6] = x-3;
|
||||
playerp->legs[7] = y+12;
|
||||
playerp->legs[4] = float(x-3);
|
||||
playerp->legs[5] = float(y+12);
|
||||
playerp->legs[6] = float(x-3);
|
||||
playerp->legs[7] = float(y+12);
|
||||
|
||||
playerp->legs[8] = x+1;
|
||||
playerp->legs[9] = y+6;
|
||||
playerp->legs[10] = x+1;
|
||||
playerp->legs[11] = y+6;
|
||||
playerp->legs[8] = float(x+1);
|
||||
playerp->legs[9] = float(y+6);
|
||||
playerp->legs[10] = float(x+1);
|
||||
playerp->legs[11] = float(y+6);
|
||||
|
||||
playerp->legs[12] = x+3;
|
||||
playerp->legs[13] = y+12;
|
||||
playerp->legs[14] = x+3;
|
||||
playerp->legs[15] = y+12;
|
||||
playerp->legs[12] = float(x+3);
|
||||
playerp->legs[13] = float(y+12);
|
||||
playerp->legs[14] = float(x+3);
|
||||
playerp->legs[15] = float(y+12);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
playerp->accs[i] = 0;
|
||||
|
@ -71,8 +71,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[i].tmp = parts[ID(r)].type;
|
||||
parts[i].temp = parts[ID(r)].temp;
|
||||
parts[i].tmp2 = parts[ID(r)].life;
|
||||
parts[i].pavg[0] = parts[ID(r)].tmp;
|
||||
parts[i].pavg[1] = parts[ID(r)].ctype;
|
||||
parts[i].pavg[0] = float(parts[ID(r)].tmp);
|
||||
parts[i].pavg[1] = float(parts[ID(r)].ctype);
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
if(parts[i].tmp && TYP(r)==PT_SPRK && parts[ID(r)].ctype==PT_PSCN && parts[ID(r)].life>0 && parts[ID(r)].life<4)
|
||||
@ -84,8 +84,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
parts[np].temp = parts[i].temp;
|
||||
parts[np].life = parts[i].tmp2;
|
||||
parts[np].tmp = parts[i].pavg[0];
|
||||
parts[np].ctype = parts[i].pavg[1];
|
||||
parts[np].tmp = int(parts[i].pavg[0]);
|
||||
parts[np].ctype = int(parts[i].pavg[1]);
|
||||
parts[i].tmp = 0;
|
||||
parts[i].life = 10;
|
||||
break;
|
||||
|
@ -94,7 +94,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].tmp == 1 && TYP(r) != PT_TSNS && TYP(r) != PT_FILT)
|
||||
{
|
||||
setFilt = true;
|
||||
photonWl = parts[ID(r)].temp;
|
||||
photonWl = int(parts[ID(r)].temp);
|
||||
}
|
||||
}
|
||||
if (setFilt)
|
||||
|
@ -105,7 +105,7 @@ int Element_VIRS_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r) == PT_PLSM)
|
||||
{
|
||||
if (surround_space && RNG::Ref().chance(10 + sim->pv[(y+ry)/CELL][(x+rx)/CELL], 100))
|
||||
if (surround_space && RNG::Ref().chance(10 + int(sim->pv[(y+ry)/CELL][(x+rx)/CELL]), 100))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PLSM);
|
||||
return 1;
|
||||
|
@ -108,7 +108,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (vel >= 0 && vel < SIM_MAXVELOCITY)
|
||||
{
|
||||
doDeserialization = true;
|
||||
Vs = vel;
|
||||
Vs = float(vel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -72,10 +72,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
parts[i].x = parts[ID(r)].x;
|
||||
parts[i].y = parts[ID(r)].y;
|
||||
parts[ID(r)].x = x;
|
||||
parts[ID(r)].y = y;
|
||||
parts[ID(r)].x = float(x);
|
||||
parts[ID(r)].y = float(y);
|
||||
parts[ID(r)].vx = RNG::Ref().chance(-2, 1) + 0.5f;
|
||||
parts[ID(r)].vy = RNG::Ref().between(-2, 1);
|
||||
parts[ID(r)].vy = float(RNG::Ref().between(-2, 1));
|
||||
parts[i].life += 4;
|
||||
pmap[y][x] = r;
|
||||
pmap[y+ry][x+rx] = PMAP(i, parts[i].type);
|
||||
|
@ -85,9 +85,9 @@ constexpr float FREQUENCY = 0.0628f;
|
||||
static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int q = (int)((cpart->temp-73.15f)/100+1);
|
||||
*colr = sin(FREQUENCY*q + 0) * 127 + 128;
|
||||
*colg = sin(FREQUENCY*q + 2) * 127 + 128;
|
||||
*colb = sin(FREQUENCY*q + 4) * 127 + 128;
|
||||
*colr = int(sin(FREQUENCY*q + 0) * 127 + 128);
|
||||
*colg = int(sin(FREQUENCY*q + 2) * 127 + 128);
|
||||
*colb = int(sin(FREQUENCY*q + 4) * 127 + 128);
|
||||
*pixel_mode |= EFFECT_DBGLINES;
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX,
|
||||
float *vx = &sim->air->vx[y / CELL][x / CELL];
|
||||
float *vy = &sim->air->vy[y / CELL][x / CELL];
|
||||
|
||||
float dvx = brushX - x;
|
||||
float dvy = brushY - y;
|
||||
auto dvx = float(brushX - x);
|
||||
auto dvy = float(brushY - y);
|
||||
float invsqr = 1/sqrtf(dvx*dvx + dvy*dvy);
|
||||
|
||||
*vx -= (strength / 16) * (-dvy)*invsqr;
|
||||
|
@ -42,12 +42,12 @@ static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX,
|
||||
return 0;
|
||||
|
||||
sim->pmap[y][x] = thatPart;
|
||||
sim->parts[ID(thatPart)].x = x;
|
||||
sim->parts[ID(thatPart)].y = y;
|
||||
sim->parts[ID(thatPart)].x = float(x);
|
||||
sim->parts[ID(thatPart)].y = float(y);
|
||||
|
||||
sim->pmap[newY][newX] = thisPart;
|
||||
sim->parts[ID(thisPart)].x = newX;
|
||||
sim->parts[ID(thisPart)].y = newY;
|
||||
sim->parts[ID(thisPart)].x = float(newX);
|
||||
sim->parts[ID(thisPart)].y = float(newY);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -101,17 +101,17 @@ void TaskWindow::OnDraw()
|
||||
progress = 100;
|
||||
float size = float(Size.X-4)*(float(progress)/100.0f); // TIL...
|
||||
size = std::min(std::max(size, 0.0f), float(Size.X-4));
|
||||
g->fillrect(Position.X + 2, Position.Y + Size.Y-15, size, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
g->fillrect(Position.X + 2, Position.Y + Size.Y-15, int(size), 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
}
|
||||
} else {
|
||||
int size = 40, rsize = 0;
|
||||
float position = float(Size.X-4)*(intermediatePos/100.0f);
|
||||
if(position + size - 1 > Size.X-4)
|
||||
{
|
||||
size = (Size.X-4)-position+1;
|
||||
size = (Size.X-4)-int(position)+1;
|
||||
rsize = 40-size;
|
||||
}
|
||||
g->fillrect(Position.X + 2 + position, Position.Y + Size.Y-15, size, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
g->fillrect(Position.X + 2 + int(position), Position.Y + Size.Y-15, size, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
if(rsize)
|
||||
{
|
||||
g->fillrect(Position.X + 2, Position.Y + Size.Y-15, rsize, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);
|
||||
|
Loading…
x
Reference in New Issue
Block a user