fix all the gcc warnings in the element files (except one in PSTN) + all the unused variable warnings

This commit is contained in:
jacob1 2015-01-10 22:43:33 -05:00
parent a5797f6262
commit dce874484a
49 changed files with 109 additions and 187 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -295,7 +295,6 @@ void blit2(pixel * vid, int currentScale)
int SDLOpen()
{
SDL_Surface * surface;
#if defined(WIN) && defined(WINCONSOLE)
FILE * console = fopen("CON", "w" );
#endif
@ -839,7 +838,7 @@ int main(int argc, char * argv[])
if(tempScale != 1 && tempScale != 2)
tempScale = 1;
int sdlStatus = SDLOpen();
SDLOpen();
#ifdef WIN
LoadWindowPosition(tempScale);
#endif

View File

@ -712,31 +712,25 @@ void Client::Tick()
#ifndef IGNORE_UPDATES
//Check for updates
json::Object versions = objDocument["Updates"];
#if not defined(BETA) && not defined(SNAPSHOT)
json::Object stableVersion = versions["Stable"];
json::Object betaVersion = versions["Beta"];
json::Object snapshotVersion = versions["Snapshot"];
json::Number stableMajor = stableVersion["Major"];
json::Number stableMinor = stableVersion["Minor"];
json::Number stableBuild = stableVersion["Build"];
json::String stableFile = stableVersion["File"];
json::Number betaMajor = betaVersion["Major"];
json::Number betaMinor = betaVersion["Minor"];
json::Number betaBuild = betaVersion["Build"];
json::String betaFile = betaVersion["File"];
json::Number snapshotSnapshot = snapshotVersion["Snapshot"];
json::String snapshotFile = snapshotVersion["File"];
if(stableMajor.Value()>SAVE_VERSION || (stableMinor.Value()>MINOR_VERSION && stableMajor.Value()==SAVE_VERSION) || stableBuild.Value()>BUILD_NUM)
{
updateAvailable = true;
updateInfo = UpdateInfo(stableMajor.Value(), stableMinor.Value(), stableBuild.Value(), stableFile.Value(), UpdateInfo::Stable);
}
#endif
#ifdef BETA
json::Object betaVersion = versions["Beta"];
json::Number betaMajor = betaVersion["Major"];
json::Number betaMinor = betaVersion["Minor"];
json::Number betaBuild = betaVersion["Build"];
json::String betaFile = betaVersion["File"];
if(betaMajor.Value()>SAVE_VERSION || (betaMinor.Value()>MINOR_VERSION && betaMajor.Value()==SAVE_VERSION) || betaBuild.Value()>BUILD_NUM)
{
updateAvailable = true;
@ -745,6 +739,9 @@ void Client::Tick()
#endif
#ifdef SNAPSHOT
json::Object snapshotVersion = versions["Snapshot"];
json::Number snapshotSnapshot = snapshotVersion["Snapshot"];
json::String snapshotFile = snapshotVersion["File"];
if(snapshotSnapshot.Value() > SNAPSHOT_ID)
{
updateAvailable = true;

View File

@ -1094,9 +1094,9 @@ fin:
void GameSave::readPSv(char * data, int dataLength)
{
unsigned char * d = NULL, * c = (unsigned char *)data;
int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0, tempGrav = 0;
int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0;
int bx0=0, by0=0, bw, bh, w, h, y0 = 0, x0 = 0;
int nf=0, new_format = 0, ttv = 0;
int new_format = 0, ttv = 0;
int *fp = (int *)malloc(NPART*sizeof(int));
std::vector<sign> tempSigns;

View File

@ -706,7 +706,6 @@ void http_auth_headers(void *ctx, const char *user, const char *pass, const char
char *tmp;
int i;
unsigned char hash[16];
unsigned int m;
struct md5_context md5;
if (user)
@ -716,7 +715,6 @@ void http_auth_headers(void *ctx, const char *user, const char *pass, const char
md5_init(&md5);
md5_update(&md5, (unsigned char *)user, strlen(user));
md5_update(&md5, (unsigned char *)"-", 1);
m = 0;
md5_update(&md5, (unsigned char *)pass, strlen(pass));
md5_final(hash, &md5);

View File

@ -1119,11 +1119,12 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve
}
}
void Graphics::draw_rgba_image(unsigned char *data, int x, int y, float alpha)
void Graphics::draw_rgba_image(const unsigned char *data_, int x, int y, float alpha)
{
unsigned char w, h;
int i, j;
unsigned char r, g, b, a;
unsigned char *data = (unsigned char*)data_;
if (!data) return;
w = *(data++)&0xFF;
h = *(data++)&0xFF;

View File

@ -247,7 +247,7 @@ public:
void draw_image(pixel *img, int x, int y, int w, int h, int a);
void draw_image(const VideoBuffer & vidBuf, int w, int h, int a);
void draw_image(VideoBuffer * vidBuf, int w, int h, int a);
void draw_rgba_image(unsigned char *data, int x, int y, float alpha);
void draw_rgba_image(const unsigned char *data, int x, int y, float alpha);
Graphics();
~Graphics();

View File

@ -16,7 +16,6 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
{
if(!strlen(s))
return 0;
int width, height;
int invert = 0;
int oR = r, oG = g, oB = b;

View File

@ -521,7 +521,7 @@ wall_type * Renderer_wtypes = LoadWalls(Renderer_wtypesCount);
VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
{
int i, j, cr, cg, cb;
int i, j;
int wt = wallID;
if (wt<0 || wt>=Renderer_wtypesCount)
return 0;
@ -912,7 +912,7 @@ void Renderer::DrawWalls()
void Renderer::DrawSigns()
{
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq,match;
int i, j, x, y, w, h, dx, dy;
std::vector<sign> signs = sim->signs;
#ifdef OGLR
GLint prevFbo;
@ -1004,7 +1004,7 @@ void Renderer::render_fire()
#ifndef OGLR
if(!(render_mode & FIREMODE))
return;
int i,j,x,y,r,g,b,nx,ny;
int i,j,x,y,r,g,b;
for (j=0; j<YRES/CELL; j++)
for (i=0; i<XRES/CELL; i++)
{
@ -1043,7 +1043,7 @@ float blur_alphaf[7][7];
void Renderer::prepare_alpha(int size, float intensity)
{
//TODO: implement size
int x,y,i,j,c;
int x,y,i,j;
float multiplier = 255.0f*intensity;
memset(temp, 0, sizeof(temp));
@ -1071,7 +1071,7 @@ void Renderer::prepare_alpha(int size, float intensity)
memset(glow_alphaf, 0, sizeof(glow_alphaf));
c = 5;
int c = 5;
glow_alphaf[c][c-1] = 0.4f;
glow_alphaf[c][c+1] = 0.4f;
@ -1125,7 +1125,7 @@ void Renderer::render_parts()
{
int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y, caddress;
int orbd[4] = {0, 0, 0, 0}, orbl[4] = {0, 0, 0, 0};
float gradv, flicker, fnx, fny;
float gradv, flicker;
Particle * parts;
Element *elements;
if(!sim)
@ -1133,6 +1133,7 @@ void Renderer::render_parts()
parts = sim->parts;
elements = sim->elements;
#ifdef OGLR
float fnx, fny;
int cfireV = 0, cfireC = 0, cfire = 0;
int csmokeV = 0, csmokeC = 0, csmoke = 0;
int cblobV = 0, cblobC = 0, cblob = 0;
@ -1168,8 +1169,10 @@ void Renderer::render_parts()
nx = (int)(sim->parts[i].x+0.5f);
ny = (int)(sim->parts[i].y+0.5f);
#ifdef OGLR
fnx = sim->parts[i].x;
fny = sim->parts[i].y;
#endif
if(nx >= XRES || nx < 0 || ny >= YRES || ny < 0)
continue;

View File

@ -8,7 +8,6 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
ui::Window(ui::Point(-1, -1), ui::Point(250, 35)),
callback(callback_)
{
int width, height;
ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), title);
titleLabel->SetTextColour(style::Colour::WarningTitle);
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
@ -64,7 +63,6 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string
ui::Window(ui::Point(-1, -1), ui::Point(250, 50)),
callback(callback_)
{
int width, height;
ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), title);
titleLabel->SetTextColour(style::Colour::WarningTitle);
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;

View File

@ -3,7 +3,7 @@
void Brush::RenderRect(Renderer * ren, ui::Point position1, ui::Point position2)
{
int width, height, t;
int width, height;
width = position2.X-position1.X;
height = position2.Y-position1.Y;
if(height<0)

View File

@ -11,7 +11,7 @@ public:
Brush(size_)
{
SetRadius(size_);
};
}
virtual void GenerateBitmap()
{
if(bitmap)
@ -29,7 +29,7 @@ public:
}
else
{
int yTop = ry+1, yBottom, i, j;
int yTop = ry+1, yBottom, i;
for (i = 0; i <= rx; i++)
{
while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0))

View File

@ -21,7 +21,6 @@ namespace ui
ui::Button::OnMouseClick(x, y, button);
ClipboardPush((char*)ButtonText.c_str());
int textWidth = Graphics::textwidth("Copied!");
copyTextLabel->SetText("Copied!");
Appearance.TextInactive = ui::Colour(180, 230, 180);

View File

@ -135,7 +135,6 @@ void ScrollPanel::XTick(float dt)
int oldOffsetY = offsetY;
offsetY += yScrollVel;
int oldOffsetX = offsetX;
offsetX += xScrollVel;
yScrollVel*=0.98f;

View File

@ -25,7 +25,6 @@ void Slider::updatePosition(int position)
float fPosition = position-3;
float fSize = Size.X-6;
float fSteps = sliderSteps;
float fSliderPosition = (fPosition/fSize)*sliderSteps;//position;//((x-3)/(Size.X-6))*sliderSteps;

View File

@ -565,7 +565,6 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
ui::AvatarButton * tempAvatar;
for(int i = 0; i < comments->size(); i++)
{
int usernameY = currentY+5, commentY;
if(showAvatars)
{
tempAvatar = new ui::AvatarButton(ui::Point(2, currentY+7), ui::Point(26, 26), comments->at(i)->authorName);
@ -589,7 +588,6 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
commentComponents.push_back(tempUsername);
commentsPanel->AddChild(tempUsername);
commentY = currentY+5;
if(showAvatars)
tempComment = new ui::Label(ui::Point(31, currentY+5), ui::Point(Size.X-((XRES/2) + 13 + 26), -1), comments->at(i)->comment);
else

View File

@ -468,8 +468,8 @@ void SearchView::CheckAccess()
void SearchView::NotifyTagListChanged(SearchModel * sender)
{
int i = 0;
int buttonWidth, buttonHeight, saveX = 0, saveY = 0, savesX = 5, savesY = 4, buttonPadding = 1;
int buttonAreaWidth, buttonAreaHeight, buttonXOffset, buttonYOffset;
int savesY = 4, buttonPadding = 1;
int buttonAreaHeight, buttonYOffset;
int tagWidth, tagHeight, tagX = 0, tagY = 0, tagsX = 6, tagsY = 4, tagPadding = 1;
int tagAreaWidth, tagAreaHeight, tagXOffset, tagYOffset;
@ -490,8 +490,6 @@ void SearchView::NotifyTagListChanged(SearchModel * sender)
tagButtons.clear();
buttonYOffset = 28;
buttonXOffset = buttonPadding;
buttonAreaWidth = Size.X;
buttonAreaHeight = Size.Y - buttonYOffset - 18;
if(sender->GetShowTags())
@ -576,9 +574,6 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
int buttonWidth, buttonHeight, saveX = 0, saveY = 0, savesX = 5, savesY = 4, buttonPadding = 1;
int buttonAreaWidth, buttonAreaHeight, buttonXOffset, buttonYOffset;
int tagWidth, tagHeight, tagX = 0, tagY = 0, tagsX = 6, tagsY = 4, tagPadding = 1;
int tagAreaWidth, tagAreaHeight, tagXOffset, tagYOffset;
vector<SaveInfo*> saves = sender->GetSaveList();
//string messageOfTheDay = sender->GetMessageOfTheDay();
@ -662,13 +657,6 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
buttonYOffset += (buttonAreaHeight/savesY) - buttonPadding*2;
buttonAreaHeight = Size.Y - buttonYOffset - 18;
savesY--;
tagXOffset = tagPadding;
tagYOffset = 60;
tagAreaWidth = Size.X;
tagAreaHeight = ((buttonAreaHeight/savesY) - buttonPadding*2)-(tagYOffset-28)-5;
tagWidth = (tagAreaWidth/tagsX) - tagPadding*2;
tagHeight = (tagAreaHeight/tagsY) - tagPadding*2;
}
buttonWidth = (buttonAreaWidth/savesX) - buttonPadding*2;

View File

@ -58,8 +58,7 @@ int luacon_partread(lua_State* l)
int luacon_partwrite(lua_State* l)
{
int tempinteger, i = cIndex;
float tempfloat;
int i = cIndex;
std::string key = luaL_optstring(l, 2, "");
CommandInterface::FormatType format;
int offset = luacon_ci->GetPropertyOffset(key, format);
@ -1260,13 +1259,8 @@ int luatpt_set_elecmap(lua_State* l)
int luatpt_get_elecmap(lua_State* l)
{
int nx, ny, acount;
int x1, y1, width, height;
float value;
acount = lua_gettop(l);
x1 = abs(luaL_optint(l, 1, 0));
y1 = abs(luaL_optint(l, 2, 0));
int x1 = abs(luaL_optint(l, 1, 0));
int y1 = abs(luaL_optint(l, 2, 0));
if(x1 > (XRES/CELL) || y1 > (YRES/CELL))
return luaL_error(l, "Out of range");

View File

@ -709,7 +709,7 @@ int LuaScriptInterface::simulation_partNeighbours(lua_State * l)
int LuaScriptInterface::simulation_partChangeType(lua_State * l)
{
int partIndex = lua_tointeger(l, 1), x, y;
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));
@ -1455,7 +1455,7 @@ int LuaScriptInterface::simulation_saveStamp(lua_State * l)
int LuaScriptInterface::simulation_loadStamp(lua_State * l)
{
int i = -1, j, x, y;
int i = -1, x, y;
SaveFile * tempfile;
x = luaL_optint(l,2,0);
y = luaL_optint(l,3,0);
@ -3099,7 +3099,6 @@ std::string highlight(std::string command)
#define CMP(X) (!strlcmp(wstart, X, len))
std::stringstream result;
int pos = 0;
int len = command.length();
const char *raw = command.c_str();
char c;
while(c = raw[pos])

View File

@ -56,7 +56,7 @@ int TPTScriptInterface::Command(std::string command)
}
//Evaluate
return 0;
return retCode;
}
ValueType TPTScriptInterface::testType(std::string word)
@ -81,7 +81,6 @@ ValueType TPTScriptInterface::testType(std::string word)
else if(word == "quit")
return TypeFunction;
//Basic type
parseNumber:
for(i = 0; i < word.length(); i++)
{
if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i))

View File

@ -76,8 +76,12 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
size_t size = 0, sent = 0;
const char *data = luaL_checklstring(L, 2, &size);
long start = (long) luaL_optnumber(L, 3, 1);
long end = (long) luaL_optnumber(L, 4, -1);
p_timeout tm = timeout_markstart(buf->tm);
long end = (long) luaL_optnumber(L, 4, -1);
#ifdef LUASOCKET_DEBUG
p_timeout tm = timeout_markstart(buf->tm);
#else
timeout_markstart(buf->tm); //not sure if this is needed, but prevent warning anyway
#endif
if (start < 0) start = (long) (size+start+1);
if (end < 0) end = (long) (size+end+1);
if (start < 1) start = (long) 1;
@ -108,7 +112,11 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
luaL_Buffer b;
size_t size;
const char *part = luaL_optlstring(L, 3, "", &size);
#ifdef LUASOCKET_DEBUG
p_timeout tm = timeout_markstart(buf->tm);
#else
timeout_markstart(buf->tm);
#endif
/* initialize buffer with optional extra prefix
* (useful for concatenating previous partial results) */
luaL_buffinit(L, &b);

View File

@ -200,7 +200,7 @@ GameSave * Simulation::Save()
GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
{
int blockX, blockY, blockX2, blockY2, fullW, fullH, blockW, blockH;
int blockX, blockY, blockX2, blockY2, blockW, blockH;
//Normalise incoming coords
int swapTemp;
if(fullY>fullY2)
@ -223,16 +223,8 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
blockX2 = (fullX2+CELL)/CELL;
blockY2 = (fullY2+CELL)/CELL;
//fullX = blockX*CELL;
//fullY = blockY*CELL;
//fullX2 = blockX2*CELL;
//fullY2 = blockY2*CELL;
blockW = blockX2-blockX;
blockH = blockY2-blockY;
fullW = fullX2-fullX;
fullH = fullY2-fullY;
GameSave * newSave = new GameSave(blockW, blockH);
@ -1771,13 +1763,12 @@ void Simulation::create_arc(int sx, int sy, int dx, int dy, int midpoints, int v
void Simulation::clear_sim(void)
{
int i, x, y;
emp_decor = 0;
signs.clear();
memset(bmap, 0, sizeof(bmap));
memset(emap, 0, sizeof(emap));
memset(parts, 0, sizeof(Particle)*NPART);
for (i=0; i<NPART-1; i++)
for (int i = 0; i < NPART-1; i++)
parts[i].life = i+1;
parts[NPART-1].life = -1;
pfree = 0;
@ -3163,7 +3154,7 @@ void Simulation::create_gain_photon(int pp)//photons from PHOT going through GLO
void Simulation::create_cherenkov_photon(int pp)//photons from NEUT going through GLAS
{
int i, lr, nx, ny;
float r, eff_ior;
float r;
if (pfree == -1)
return;
@ -3715,12 +3706,11 @@ void Simulation::update_particles_i(int start, int inc)
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)>(rand()%250))
#endif
{
float c_Cm = 0.0f;
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
{
#ifdef REALISTIC
c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256;
c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256;
float c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256;
pt = c_heat/c_Cm;
pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
parts[i].temp = pt;
@ -3735,7 +3725,9 @@ void Simulation::update_particles_i(int start, int inc)
#endif
}
c_heat = 0.0f;
c_Cm = 0.0f;
#ifdef REALISTIC
float c_Cm = 0.0f;
#endif
for (j=0; j<8; j++)
{
surround_hconduct[j] = i;

View File

@ -49,7 +49,7 @@ Element_ACID::Element_ACID()
//#TPT-Directive ElementHeader Element_ACID static int update(UPDATE_FUNC_ARGS)
int Element_ACID::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, np;
int r, rx, ry, trade;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))

View File

@ -49,7 +49,7 @@ Element_ARAY::Element_ARAY()
//#TPT-Directive ElementHeader Element_ARAY static int update(UPDATE_FUNC_ARGS)
int Element_ARAY::update(UPDATE_FUNC_ARGS)
{
int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1;
int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, ry1, rx1;
if (parts[i].life==0) {
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)

View File

@ -49,7 +49,7 @@ Element_BANG::Element_BANG()
//#TPT-Directive ElementHeader Element_BANG static int update(UPDATE_FUNC_ARGS)
int Element_BANG::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, nb;
int r, rx, ry;
if(parts[i].tmp==0)
{
if(parts[i].temp>=673.0f)

View File

@ -49,7 +49,7 @@ Element_BMTL::Element_BMTL()
//#TPT-Directive ElementHeader Element_BMTL static int update(UPDATE_FUNC_ARGS)
int Element_BMTL::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, tempFactor;
int r, rx, ry;
if (parts[i].tmp>1)
{
parts[i].tmp--;

View File

@ -49,7 +49,6 @@ Element_BREC::Element_BREC()
//#TPT-Directive ElementHeader Element_BREC static int update(UPDATE_FUNC_ARGS)
int Element_BREC::update(UPDATE_FUNC_ARGS)
{
int np;
if (parts[i].life)
{
if (sim->pv[y/CELL][x/CELL]>10.0f)

View File

@ -49,7 +49,7 @@ Element_BRMT::Element_BRMT()
//#TPT-Directive ElementHeader Element_BRMT static int update(UPDATE_FUNC_ARGS)
int Element_BRMT::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, tempFactor;
int r, rx, ry, tempFactor;
if (parts[i].temp > 523.15f)//250.0f+273.15f
{
tempFactor = 1000 - ((523.15f-parts[i].temp)*2);

View File

@ -49,7 +49,7 @@ Element_CAUS::Element_CAUS()
//#TPT-Directive ElementHeader Element_CAUS static int update(UPDATE_FUNC_ARGS)
int Element_CAUS::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, np;
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))

View File

@ -49,7 +49,7 @@ Element_COAL::Element_COAL()
//#TPT-Directive ElementHeader Element_COAL static int update(UPDATE_FUNC_ARGS)
int Element_COAL::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, temp, t = parts[i].type;
int t = parts[i].type;
if (parts[i].life<=0) {
sim->create_part(i, x, y, PT_FIRE);
return 1;
@ -68,36 +68,6 @@ int Element_COAL::update(UPDATE_FUNC_ARGS)
return 1;
}
}
/*if(100-parts[i].life > parts[i].tmp2)
parts[i].tmp2 = 100-parts[i].life;
if(parts[i].tmp2 < 0) parts[i].tmp2 = 0;
for ( trade = 0; trade<4; trade ++)
{
rx = rand()%5-2;
ry = rand()%5-2;
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion
{
int temp = parts[i].tmp2 - parts[r>>8].tmp2;
if(temp < 10)
continue;
if (temp ==1)
{
parts[r>>8].tmp2 ++;
parts[i].tmp2 --;
}
else if (temp>0)
{
parts[r>>8].tmp2 += temp/2;
parts[i].tmp2 -= temp/2;
}
}
}
}*/
if(parts[i].temp > parts[i].tmp2)
parts[i].tmp2 = parts[i].temp;
return 0;

View File

@ -49,7 +49,7 @@ Element_CRAY::Element_CRAY()
//#TPT-Directive ElementHeader Element_CRAY static int update(UPDATE_FUNC_ARGS)
int Element_CRAY::update(UPDATE_FUNC_ARGS)
{
int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1;
int r, nxx, nyy, docontinue, nxi, nyi, rx, ry;
// set ctype to things that touch it if it doesn't have one already
if(parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled) {
int r, rx, ry;
@ -78,7 +78,6 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) { //spark found, start creating
unsigned int colored = 0;
bool isBlackDeco = false;
bool destroy = parts[r>>8].ctype==PT_PSCN;
bool nostop = parts[r>>8].ctype==PT_INST;
bool createSpark = (parts[r>>8].ctype==PT_INWR);
@ -134,7 +133,6 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
unsigned int Element_CRAY::wavelengthToDecoColour(int wavelength)
{
int colr = 0, colg = 0, colb = 0, x;
unsigned int dcolour = 0;
for (x=0; x<12; x++) {
colr += (wavelength >> (x+18)) & 1;
colb += (wavelength >> x) & 1;

View File

@ -49,14 +49,10 @@ Element_DEST::Element_DEST()
//#TPT-Directive ElementHeader Element_DEST static int update(UPDATE_FUNC_ARGS)
int Element_DEST::update(UPDATE_FUNC_ARGS)
{
int r,rx,ry,topv;
rx=rand()%5-2;
ry=rand()%5-2;
if (!BOUNDS_CHECK)
return 1;
r = pmap[y+ry][x+rx];
if (!r || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_PBCN)
int rx = rand()%5-2;
int ry = rand()%5-2;
int r = pmap[y+ry][x+rx];
if (!r || !BOUNDS_CHECK || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_PBCN)
return 0;
if (parts[i].life<=0 || parts[i].life>37)

View File

@ -49,7 +49,7 @@ Element_DMG::Element_DMG()
//#TPT-Directive ElementHeader Element_DMG static int update(UPDATE_FUNC_ARGS)
int Element_DMG::update(UPDATE_FUNC_ARGS)
{
int r, rr, rx, ry, nb, nxi, nxj, t, dist;
int r, rr, rx, ry, nxi, nxj, t, dist;
int rad = 25;
float angle, fx, fy;

View File

@ -49,7 +49,7 @@ Element_DSTW::Element_DSTW()
//#TPT-Directive ElementHeader Element_DSTW static int update(UPDATE_FUNC_ARGS)
int Element_DSTW::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))

View File

@ -48,7 +48,7 @@ Element_EMBR::Element_EMBR()
//#TPT-Directive ElementHeader Element_EMBR static int update(UPDATE_FUNC_ARGS)
int Element_EMBR::update(UPDATE_FUNC_ARGS) {
int r, rx, ry, nb;
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))

View File

@ -49,7 +49,7 @@ Element_EXOT::Element_EXOT()
//#TPT-Directive ElementHeader Element_EXOT static int update(UPDATE_FUNC_ARGS)
int Element_EXOT::update(UPDATE_FUNC_ARGS)
{
int r, rt, rx, ry, nb, rrx, rry, trade, tym;
int r, rt, rx, ry, trade, tym;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (BOUNDS_CHECK && (rx || ry))

View File

@ -87,7 +87,7 @@ std::vector<StructProperty> Element::GetProperties()
}
int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt;
int r, rx, ry;
int t = parts[i].type;
if (t==PT_WTRV) {
for (rx=-2; rx<3; rx++)

View File

@ -15,6 +15,10 @@ public:
const char *Identifier;
const char *Name;
pixel Colour;
int MenuVisible;
int MenuSection;
int Enabled;
float Advection;
float AirDrag;
float AirLoss;
@ -28,28 +32,26 @@ public:
int Explosive;
int Meltable;
int Hardness;
int MenuVisible;
int Enabled;
int Weight;
int MenuSection;
float Temperature;
unsigned char HeatConduct;
const char *Description;
char State;
unsigned int Properties;
float LowPressure;
int LowPressureTransition;
float HighPressure;
int HighPressureTransition;
float LowTemperature;
int LowTemperatureTransition;
float HighTemperature;
int HighTemperatureTransition;
int (*Update) (UPDATE_FUNC_ARGS);
int (*Graphics) (GRAPHICS_FUNC_ARGS);
VideoBuffer * (*IconGenerator)(int, int, int);
float HighPressure;
int HighPressureTransition;
float LowPressure;
int LowPressureTransition;
float HighTemperature;
int HighTemperatureTransition;
float LowTemperature;
int LowTemperatureTransition;
Element();
virtual ~Element() {}
static int defaultGraphics(GRAPHICS_FUNC_ARGS);

View File

@ -56,7 +56,7 @@ int Element_FIGH::update(UPDATE_FUNC_ARGS)
}
playerst* figh = &sim->fighters[(unsigned char)parts[i].tmp];
unsigned int tarx, tary;
int tarx, tary;
parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man
@ -66,20 +66,20 @@ int Element_FIGH::update(UPDATE_FUNC_ARGS)
if (sim->player.spwn && (pow((float)sim->player.legs[2]-x, 2) + pow((float)sim->player.legs[3]-y, 2))<=
(pow((float)sim->player2.legs[2]-x, 2) + pow((float)sim->player2.legs[3]-y, 2)))
{
tarx = (unsigned int)sim->player.legs[2];
tary = (unsigned int)sim->player.legs[3];
tarx = (int)sim->player.legs[2];
tary = (int)sim->player.legs[3];
}
else
{
tarx = (unsigned int)sim->player2.legs[2];
tary = (unsigned int)sim->player2.legs[3];
tarx = (int)sim->player2.legs[2];
tary = (int)sim->player2.legs[3];
}
parts[i].tmp2 = 1;
}
else if (sim->player.spwn)
{
tarx = (unsigned int)sim->player.legs[2];
tary = (unsigned int)sim->player.legs[3];
tarx = (int)sim->player.legs[2];
tary = (int)sim->player.legs[3];
parts[i].tmp2 = 1;
}

View File

@ -49,7 +49,6 @@ Element_FWRK::Element_FWRK()
//#TPT-Directive ElementHeader Element_FWRK static int update(UPDATE_FUNC_ARGS)
int Element_FWRK::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, np;
if (parts[i].life==0 && ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&surround_space)||parts[i].ctype==PT_DUST))
{
float gx, gy, multiplier, gmax;
@ -92,7 +91,7 @@ int Element_FWRK::update(UPDATE_FUNC_ARGS)
unsigned col = (r<<16) | (g<<8) | b;
for (n=0; n<40; n++)
{
np = sim->create_part(-3, x, y, PT_EMBR);
int np = sim->create_part(-3, x, y, PT_EMBR);
if (np>-1)
{
magnitude = ((rand()%60)+40)*0.05f;

View File

@ -50,7 +50,7 @@ Element_GOLD::Element_GOLD()
//#TPT-Directive ElementHeader Element_GOLD static int update(UPDATE_FUNC_ARGS)
int Element_GOLD::update(UPDATE_FUNC_ARGS)
{
int rx, ry, r, rndstore, blocking = 0;
int rx, ry, r, rndstore;
static int checkCoordsX[] = { -4, 4, 0, 0 };
static int checkCoordsY[] = { 0, 0, -4, 4 };
//Find nearby rusted iron (BMTL with tmp 1+)

View File

@ -49,7 +49,7 @@ Element_IRON::Element_IRON()
//#TPT-Directive ElementHeader Element_IRON static int update(UPDATE_FUNC_ARGS)
int Element_IRON::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
int r, rx, ry;
if (parts[i].life)
return 0;
for (rx=-1; rx<2; rx++)

View File

@ -70,8 +70,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
*/
int r,rx,ry,rt, multipler, powderful;
float angle, angle2=-1;
int pNear = 0;
powderful = powderful = parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER;
powderful = parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER;
//Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
if (sim->aheat_enable)
{
@ -162,7 +161,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
}
//Completely broken and laggy function, possibly can be fixed later
/*pNear = LIGH_nearest_part(sim, i, parts[i].life*2.5);
/*int pNear = LIGH_nearest_part(sim, i, parts[i].life*2.5);
if (pNear!=-1)
{
int t=parts[pNear].type;

View File

@ -144,7 +144,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
if (parts[i].dcolour)
{
int colour=parts[i].dcolour;
parts[nr].dcolour=(colour&0xFF000000)|std::max(colour&0xFF0000-0x3C0000,0)|std::max(colour&0xFF00-0x3C00,0)|std::max(colour&0xFF-0x3C,0);
parts[nr].dcolour=(colour&0xFF000000)|std::max((colour&0xFF0000)-0x3C0000,0)|std::max((colour&0xFF00)-0x3C00,0)|std::max((colour&0xFF)-0x3C,0);
}
}
}

View File

@ -150,21 +150,10 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
int Element_QRTZ::graphics(GRAPHICS_FUNC_ARGS)
//QRTZ and PQRT
{
int t = cpart->type, z = cpart->tmp2 - 5;//speckles!
/*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz
{
float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f));
int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f);
*colr += sin(frequency*q) * 226 + (z * 16);
*colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16);
*colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16);
}
else*/
{
*colr += z * 16;
*colg += z * 16;
*colb += z * 16;
}
int z = cpart->tmp2 - 5;//speckles!
*colr += z * 16;
*colg += z * 16;
*colb += z * 16;
return 0;
}

View File

@ -49,7 +49,7 @@ Element_SING::Element_SING()
//#TPT-Directive ElementHeader Element_SING static int update(UPDATE_FUNC_ARGS)
int Element_SING::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, cry, crx, rad, nxi, nxj, nb, j, spawncount;
int r, rx, ry, cry, crx, nb, j, spawncount;
int singularity = -parts[i].life;
float angle, v;

View File

@ -200,7 +200,7 @@ int Element_TRON::new_tronhead(Simulation * sim, int x, int y, int i, int direct
sim->parts[i].life = 5;
}
//give new head our properties
sim->parts[np].tmp = 1 | direction<<5 | sim->parts[i].tmp&(TRON_NOGROW|TRON_NODIE|TRON_NORANDOM) | (sim->parts[i].tmp&0xF800);
sim->parts[np].tmp = 1 | direction<<5 | (sim->parts[i].tmp&(TRON_NOGROW|TRON_NODIE|TRON_NORANDOM)) | (sim->parts[i].tmp&0xF800);
if (np > i)
sim->parts[np].tmp |= TRON_WAIT;

View File

@ -49,7 +49,7 @@ Element_WIRE::Element_WIRE()
//#TPT-Directive ElementHeader Element_WIRE static int update(UPDATE_FUNC_ARGS)
int Element_WIRE::update(UPDATE_FUNC_ARGS)
{
int s,r,rx,ry,count=0;
int r,rx,ry,count=0;
/*
0: wire
1: spark head