add some defines to reduce usages of hardcoded r>>8

This commit is contained in:
jacob1 2017-12-28 12:03:26 -05:00
parent fbf7210814
commit ac24810da5
102 changed files with 632 additions and 627 deletions

View File

@ -97,7 +97,7 @@ Client::Client():
std::string SessionKey = preferences["User"]["SessionKey"].asString(); std::string SessionKey = preferences["User"]["SessionKey"].asString();
std::string Elevation = preferences["User"]["Elevation"].asString(); std::string Elevation = preferences["User"]["Elevation"].asString();
authUser.ID = ID; authUser.UserID = ID;
authUser.Username = Username; authUser.Username = Username;
authUser.SessionID = SessionID; authUser.SessionID = SessionID;
authUser.SessionKey = SessionKey; authUser.SessionKey = SessionKey;
@ -149,9 +149,9 @@ void Client::Initialise(std::string proxyString)
//Begin version check //Begin version check
versionCheckRequest = http_async_req_start(NULL, "http://" SERVER "/Startup.json", NULL, 0, 0); versionCheckRequest = http_async_req_start(NULL, "http://" SERVER "/Startup.json", NULL, 0, 0);
if (authUser.ID) if (authUser.UserID)
{ {
std::string idTempString = format::NumberToString<int>(authUser.ID); std::string idTempString = format::NumberToString<int>(authUser.UserID);
char *id = new char[idTempString.length() + 1]; char *id = new char[idTempString.length() + 1];
std::strcpy (id, idTempString.c_str()); std::strcpy (id, idTempString.c_str());
char *session = new char[authUser.SessionID.length() + 1]; char *session = new char[authUser.SessionID.length() + 1];
@ -945,9 +945,9 @@ void Client::WritePrefs()
if (configFile) if (configFile)
{ {
if (authUser.ID) if (authUser.UserID)
{ {
preferences["User"]["ID"] = authUser.ID; preferences["User"]["ID"] = authUser.UserID;
preferences["User"]["SessionID"] = authUser.SessionID; preferences["User"]["SessionID"] = authUser.SessionID;
preferences["User"]["SessionKey"] = authUser.SessionKey; preferences["User"]["SessionKey"] = authUser.SessionKey;
preferences["User"]["Username"] = authUser.Username; preferences["User"]["Username"] = authUser.Username;
@ -1003,8 +1003,8 @@ RequestStatus Client::UploadSave(SaveInfo & save)
char * data; char * data;
int dataLength = 0; int dataLength = 0;
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
if (authUser.ID) if (authUser.UserID)
{ {
if (!save.GetGameSave()) if (!save.GetGameSave())
{ {
@ -1244,11 +1244,11 @@ RequestStatus Client::ExecVote(int saveID, int direction)
char * data; char * data;
int dataLength = 0; int dataLength = 0;
if (authUser.ID) if (authUser.UserID)
{ {
char * directionText = (char*)(direction==1?"Up":"Down"); char * directionText = (char*)(direction==1?"Up":"Down");
std::string saveIDText = format::NumberToString<int>(saveID); std::string saveIDText = format::NumberToString<int>(saveID);
std::string userIDText = format::NumberToString<int>(authUser.ID); std::string userIDText = format::NumberToString<int>(authUser.UserID);
char *id = new char[saveIDText.length() + 1]; char *id = new char[saveIDText.length() + 1];
std::strcpy(id, saveIDText.c_str()); std::strcpy(id, saveIDText.c_str());
@ -1399,7 +1399,7 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
char passwordHash[33]; char passwordHash[33];
char totalHash[33]; char totalHash[33];
user.ID = 0; user.UserID = 0;
user.Username = ""; user.Username = "";
user.SessionID = ""; user.SessionID = "";
user.SessionKey = ""; user.SessionKey = "";
@ -1443,7 +1443,7 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
} }
user.Username = username; user.Username = username;
user.ID = userIDTemp; user.UserID = userIDTemp;
user.SessionID = sessionIDTemp; user.SessionID = sessionIDTemp;
user.SessionKey = sessionKeyTemp; user.SessionKey = sessionKeyTemp;
std::string userElevation = userElevationTemp; std::string userElevation = userElevationTemp;
@ -1472,10 +1472,10 @@ RequestStatus Client::DeleteSave(int saveID)
char * data = NULL; char * data = NULL;
int dataStatus, dataLength; int dataStatus, dataLength;
urlStream << "http://" << SERVER << "/Browse/Delete.json?ID=" << saveID << "&Mode=Delete&Key=" << authUser.SessionKey; urlStream << "http://" << SERVER << "/Browse/Delete.json?ID=" << saveID << "&Mode=Delete&Key=" << authUser.SessionKey;
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
else else
@ -1495,10 +1495,10 @@ RequestStatus Client::AddComment(int saveID, std::string comment)
char * data = NULL; char * data = NULL;
int dataStatus, dataLength; int dataStatus, dataLength;
urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID; urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID;
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
const char *const postNames[] = { "Comment", NULL }; const char *const postNames[] = { "Comment", NULL };
const char *const postDatas[] = { (char*)(comment.c_str()) }; const char *const postDatas[] = { (char*)(comment.c_str()) };
@ -1524,10 +1524,10 @@ RequestStatus Client::FavouriteSave(int saveID, bool favourite)
urlStream << "http://" << SERVER << "/Browse/Favourite.json?ID=" << saveID << "&Key=" << authUser.SessionKey; urlStream << "http://" << SERVER << "/Browse/Favourite.json?ID=" << saveID << "&Key=" << authUser.SessionKey;
if(!favourite) if(!favourite)
urlStream << "&Mode=Remove"; urlStream << "&Mode=Remove";
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
else else
@ -1547,10 +1547,10 @@ RequestStatus Client::ReportSave(int saveID, std::string message)
char * data = NULL; char * data = NULL;
int dataStatus, dataLength; int dataStatus, dataLength;
urlStream << "http://" << SERVER << "/Browse/Report.json?ID=" << saveID << "&Key=" << authUser.SessionKey; urlStream << "http://" << SERVER << "/Browse/Report.json?ID=" << saveID << "&Key=" << authUser.SessionKey;
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
const char *const postNames[] = { "Reason", NULL }; const char *const postNames[] = { "Reason", NULL };
const char *const postDatas[] = { (char*)(message.c_str()) }; const char *const postDatas[] = { (char*)(message.c_str()) };
@ -1574,10 +1574,10 @@ RequestStatus Client::UnpublishSave(int saveID)
char * data = NULL; char * data = NULL;
int dataStatus, dataLength; int dataStatus, dataLength;
urlStream << "http://" << SERVER << "/Browse/Delete.json?ID=" << saveID << "&Mode=Unpublish&Key=" << authUser.SessionKey; urlStream << "http://" << SERVER << "/Browse/Delete.json?ID=" << saveID << "&Mode=Unpublish&Key=" << authUser.SessionKey;
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
else else
@ -1597,10 +1597,10 @@ RequestStatus Client::PublishSave(int saveID)
char *data; char *data;
int dataStatus; int dataStatus;
urlStream << "http://" << SERVER << "/Browse/View.json?ID=" << saveID << "&Key=" << authUser.SessionKey; urlStream << "http://" << SERVER << "/Browse/View.json?ID=" << saveID << "&Key=" << authUser.SessionKey;
if (authUser.ID) if (authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
const char *const postNames[] = { "ActionPublish", NULL }; const char *const postNames[] = { "ActionPublish", NULL };
const char *const postDatas[] = { "" }; const char *const postDatas[] = { "" };
size_t postLengths[] = { 1 }; size_t postLengths[] = { 1 };
@ -1626,10 +1626,10 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
} }
char * data; char * data;
int dataStatus, dataLength; int dataStatus, dataLength;
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
else else
@ -1866,10 +1866,10 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, std::string q
{ {
urlStream << "&Category=" << format::URLEncode(category); urlStream << "&Category=" << format::URLEncode(category);
} }
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
else else
@ -1935,10 +1935,10 @@ std::list<std::string> * Client::RemoveTag(int saveID, std::string tag)
char * data = NULL; char * data = NULL;
int dataStatus, dataLength; int dataStatus, dataLength;
urlStream << "http://" << SERVER << "/Browse/EditTag.json?Op=delete&ID=" << saveID << "&Tag=" << tag << "&Key=" << authUser.SessionKey; urlStream << "http://" << SERVER << "/Browse/EditTag.json?Op=delete&ID=" << saveID << "&Tag=" << tag << "&Key=" << authUser.SessionKey;
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
else else
@ -1977,10 +1977,10 @@ std::list<std::string> * Client::AddTag(int saveID, std::string tag)
char * data = NULL; char * data = NULL;
int dataStatus, dataLength; int dataStatus, dataLength;
urlStream << "http://" << SERVER << "/Browse/EditTag.json?Op=add&ID=" << saveID << "&Tag=" << tag << "&Key=" << authUser.SessionKey; urlStream << "http://" << SERVER << "/Browse/EditTag.json?Op=add&ID=" << saveID << "&Tag=" << tag << "&Key=" << authUser.SessionKey;
if(authUser.ID) if(authUser.UserID)
{ {
std::stringstream userIDStream; std::stringstream userIDStream;
userIDStream << authUser.ID; userIDStream << authUser.UserID;
data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
} }
else else

View File

@ -11,13 +11,13 @@ public:
{ {
ElevationAdmin, ElevationModerator, ElevationNone ElevationAdmin, ElevationModerator, ElevationNone
}; };
int ID; int UserID;
std::string Username; std::string Username;
std::string SessionID; std::string SessionID;
std::string SessionKey; std::string SessionKey;
Elevation UserElevation; Elevation UserElevation;
User(int id, std::string username): User(int id, std::string username):
ID(id), UserID(id),
Username(username), Username(username),
SessionID(""), SessionID(""),
SessionKey(""), SessionKey(""),

View File

@ -6,7 +6,7 @@
class UserInfo class UserInfo
{ {
public: public:
int ID; int UserID;
int age; int age;
std::string username; std::string username;
std::string biography; std::string biography;
@ -22,7 +22,7 @@ public:
int reputation; int reputation;
UserInfo(int id, int age, std::string username, std::string biography, std::string location, std::string website, int saveCount, float averageScore, int highestScore, int topicCount, int topicReplies, int reputation): UserInfo(int id, int age, std::string username, std::string biography, std::string location, std::string website, int saveCount, float averageScore, int highestScore, int topicCount, int topicReplies, int reputation):
ID(id), UserID(id),
age(age), age(age),
username(username), username(username),
biography(biography), biography(biography),

View File

@ -98,12 +98,12 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
} }
postNames[i] = NULL; postNames[i] = NULL;
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
User user = Client::Ref().GetAuthUser(); User user = Client::Ref().GetAuthUser();
char userName[12]; char userName[12];
char *userSession = new char[user.SessionID.length() + 1]; char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.ID).c_str()); std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str()); std::strcpy(userSession, user.SessionID.c_str());
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession); HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
delete[] userSession; delete[] userSession;
@ -117,12 +117,12 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
else else
{ {
HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0); HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
User user = Client::Ref().GetAuthUser(); User user = Client::Ref().GetAuthUser();
char userName[12]; char userName[12];
char *userSession = new char[user.SessionID.length() + 1]; char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.ID).c_str()); std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str()); std::strcpy(userSession, user.SessionID.c_str());
http_auth_headers(HTTPContext, userName, NULL, userSession); http_auth_headers(HTTPContext, userName, NULL, userSession);
delete[] userSession; delete[] userSession;

View File

@ -98,7 +98,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
} }
postNames[i] = NULL; postNames[i] = NULL;
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
#ifdef DEBUG #ifdef DEBUG
std::cout << typeid(*this).name() << " Authenticated " << std::endl; std::cout << typeid(*this).name() << " Authenticated " << std::endl;
@ -106,7 +106,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
User user = Client::Ref().GetAuthUser(); User user = Client::Ref().GetAuthUser();
char userName[12]; char userName[12];
char *userSession = new char[user.SessionID.length() + 1]; char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.ID).c_str()); std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str()); std::strcpy(userSession, user.SessionID.c_str());
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession); HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
delete[] userSession; delete[] userSession;
@ -120,12 +120,12 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
else else
{ {
HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0); HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
User user = Client::Ref().GetAuthUser(); User user = Client::Ref().GetAuthUser();
char userName[12]; char userName[12];
char *userSession = new char[user.SessionID.length() + 1]; char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.ID).c_str()); std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str()); std::strcpy(userSession, user.SessionID.c_str());
http_auth_headers(HTTPContext, userName, NULL, userSession); http_auth_headers(HTTPContext, userName, NULL, userSession);
delete[] userSession; delete[] userSession;

View File

@ -6,9 +6,9 @@
class DebugInfo class DebugInfo
{ {
public: public:
DebugInfo(unsigned int id):ID(id) { } DebugInfo(unsigned int id):debugID(id) { }
virtual ~DebugInfo() { } virtual ~DebugInfo() { }
unsigned int ID; unsigned int debugID;
virtual void Draw() {} virtual void Draw() {}
// currentMouse doesn't belong but I don't want to create more hooks at the moment // currentMouse doesn't belong but I don't want to create more hooks at the moment
virtual bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse) { return true; } virtual bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse) { return true; }

View File

@ -775,7 +775,7 @@ bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl,
for(std::vector<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) for(std::vector<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++)
{ {
if ((*iter)->ID & debugFlags) if ((*iter)->debugID & debugFlags)
if (!(*iter)->KeyPress(key, character, shift, ctrl, alt, gameView->GetMousePosition())) if (!(*iter)->KeyPress(key, character, shift, ctrl, alt, gameView->GetMousePosition()))
ret = false; ret = false;
} }
@ -842,7 +842,7 @@ void GameController::Tick()
} }
for(std::vector<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) for(std::vector<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++)
{ {
if ((*iter)->ID & debugFlags) if ((*iter)->debugID & debugFlags)
(*iter)->Draw(); (*iter)->Draw();
} }
commandInterface->OnTick(); commandInterface->OnTick();
@ -1301,7 +1301,7 @@ void GameController::OpenLogin()
void GameController::OpenProfile() void GameController::OpenProfile()
{ {
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
new ProfileActivity(Client::Ref().GetAuthUser().Username); new ProfileActivity(Client::Ref().GetAuthUser().Username);
} }
@ -1408,7 +1408,7 @@ void GameController::OpenSaveWindow()
c->LoadSave(&save); c->LoadSave(&save);
} }
}; };
if(gameModel->GetUser().ID) if(gameModel->GetUser().UserID)
{ {
Simulation * sim = gameModel->GetSimulation(); Simulation * sim = gameModel->GetSimulation();
GameSave * gameSave = sim->Save(); GameSave * gameSave = sim->Save();
@ -1455,7 +1455,7 @@ void GameController::SaveAsCurrent()
} }
}; };
if(gameModel->GetSave() && gameModel->GetUser().ID && gameModel->GetUser().Username == gameModel->GetSave()->GetUserName()) if(gameModel->GetSave() && gameModel->GetUser().UserID && gameModel->GetUser().Username == gameModel->GetSave()->GetUserName())
{ {
Simulation * sim = gameModel->GetSimulation(); Simulation * sim = gameModel->GetSimulation();
GameSave * gameSave = sim->Save(); GameSave * gameSave = sim->Save();
@ -1481,7 +1481,7 @@ void GameController::SaveAsCurrent()
} }
} }
} }
else if(gameModel->GetUser().ID) else if(gameModel->GetUser().UserID)
{ {
OpenSaveWindow(); OpenSaveWindow();
} }
@ -1499,7 +1499,7 @@ void GameController::FrameStep()
void GameController::Vote(int direction) void GameController::Vote(int direction)
{ {
if(gameModel->GetSave() && gameModel->GetUser().ID && gameModel->GetSave()->GetID() && gameModel->GetSave()->GetVote()==0) if(gameModel->GetSave() && gameModel->GetUser().UserID && gameModel->GetSave()->GetID() && gameModel->GetSave()->GetVote()==0)
{ {
try try
{ {

View File

@ -92,7 +92,7 @@ GameModel::GameModel():
Favorite::Ref().LoadFavoritesFromPrefs(); Favorite::Ref().LoadFavoritesFromPrefs();
//Load last user //Load last user
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
currentUser = Client::Ref().GetAuthUser(); currentUser = Client::Ref().GetAuthUser();
} }

View File

@ -265,14 +265,14 @@ GameView::GameView():
SaveSimulationAction(GameView * _v) { v = _v; } SaveSimulationAction(GameView * _v) { v = _v; }
void ActionCallbackRight(ui::Button * sender) void ActionCallbackRight(ui::Button * sender)
{ {
if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().ID) if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().UserID)
v->c->OpenLocalSaveWindow(false); v->c->OpenLocalSaveWindow(false);
else else
v->c->OpenSaveWindow(); v->c->OpenSaveWindow();
} }
void ActionCallbackLeft(ui::Button * sender) void ActionCallbackLeft(ui::Button * sender)
{ {
if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().ID) if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().UserID)
v->c->OpenLocalSaveWindow(true); v->c->OpenLocalSaveWindow(true);
else else
v->c->SaveAsCurrent(); v->c->SaveAsCurrent();
@ -903,7 +903,7 @@ void GameView::NotifySimulationChanged(GameModel * sender)
} }
void GameView::NotifyUserChanged(GameModel * sender) void GameView::NotifyUserChanged(GameModel * sender)
{ {
if(!sender->GetUser().ID) if(!sender->GetUser().UserID)
{ {
loginButton->SetText("[sign in]"); loginButton->SetText("[sign in]");
((SplitButton*)loginButton)->SetShowSplit(false); ((SplitButton*)loginButton)->SetShowSplit(false);
@ -950,19 +950,19 @@ void GameView::NotifySaveChanged(GameModel * sender)
else else
((SplitButton*)saveSimulationButton)->SetShowSplit(false); ((SplitButton*)saveSimulationButton)->SetShowSplit(false);
reloadButton->Enabled = true; reloadButton->Enabled = true;
upVoteButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==0); upVoteButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==0);
if(sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==1) if(sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==1)
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 108, 10, 255)); upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 108, 10, 255));
else else
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
downVoteButton->Enabled = upVoteButton->Enabled; downVoteButton->Enabled = upVoteButton->Enabled;
if(sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==-1) if(sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==-1)
downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(108, 0, 10, 255)); downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(108, 0, 10, 255));
else else
downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
if (sender->GetUser().ID) if (sender->GetUser().UserID)
{ {
upVoteButton->Appearance.BorderDisabled = upVoteButton->Appearance.BorderInactive; upVoteButton->Appearance.BorderDisabled = upVoteButton->Appearance.BorderInactive;
downVoteButton->Appearance.BorderDisabled = downVoteButton->Appearance.BorderInactive; downVoteButton->Appearance.BorderDisabled = downVoteButton->Appearance.BorderInactive;
@ -2080,7 +2080,7 @@ void GameView::UpdateToolStrength()
void GameView::SetSaveButtonTooltips() void GameView::SetSaveButtonTooltips()
{ {
if (!Client::Ref().GetAuthUser().ID) if (!Client::Ref().GetAuthUser().UserID)
((SplitButton*)saveSimulationButton)->SetToolTips("Overwrite the open simulation on your hard drive.", "Save the simulation to your hard drive. Login to save online."); ((SplitButton*)saveSimulationButton)->SetToolTips("Overwrite the open simulation on your hard drive.", "Save the simulation to your hard drive. Login to save online.");
else if (ctrlBehaviour) else if (ctrlBehaviour)
((SplitButton*)saveSimulationButton)->SetToolTips("Overwrite the open simulation on your hard drive.", "Save the simulation to your hard drive."); ((SplitButton*)saveSimulationButton)->SetToolTips("Overwrite the open simulation on your hard drive.", "Save the simulation to your hard drive.");

View File

@ -24,7 +24,7 @@ PreviewController::PreviewController(int saveID, int saveDate, bool instant, Con
previewModel->UpdateSave(saveID, saveDate); previewModel->UpdateSave(saveID, saveDate);
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
previewModel->SetCommentBoxEnabled(true); previewModel->SetCommentBoxEnabled(true);
} }
@ -48,7 +48,7 @@ PreviewController::PreviewController(int saveID, bool instant, ControllerCallbac
previewModel->UpdateSave(saveID, 0); previewModel->UpdateSave(saveID, 0);
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
previewModel->SetCommentBoxEnabled(true); previewModel->SetCommentBoxEnabled(true);
} }
@ -105,7 +105,7 @@ void PreviewController::ShowLogin()
void PreviewController::NotifyAuthUserChanged(Client * sender) void PreviewController::NotifyAuthUserChanged(Client * sender)
{ {
previewModel->SetCommentBoxEnabled(sender->GetAuthUser().ID); previewModel->SetCommentBoxEnabled(sender->GetAuthUser().UserID);
} }
SaveInfo * PreviewController::GetSaveInfo() SaveInfo * PreviewController::GetSaveInfo()
@ -136,7 +136,7 @@ void PreviewController::Report(std::string message)
void PreviewController::FavouriteSave() void PreviewController::FavouriteSave()
{ {
if(previewModel->GetSaveInfo() && Client::Ref().GetAuthUser().ID) if(previewModel->GetSaveInfo() && Client::Ref().GetAuthUser().UserID)
{ {
try try
{ {

View File

@ -83,7 +83,7 @@ void PreviewModel::UpdateSave(int saveID, int saveDate)
if (saveDate) if (saveDate)
urlStream << "&Date=" << saveDate; urlStream << "&Date=" << saveDate;
saveInfoDownload = new Download(urlStream.str()); saveInfoDownload = new Download(urlStream.str());
saveInfoDownload->AuthHeaders(format::NumberToString(Client::Ref().GetAuthUser().ID), Client::Ref().GetAuthUser().SessionID); saveInfoDownload->AuthHeaders(format::NumberToString(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
saveInfoDownload->Start(); saveInfoDownload->Start();
if (!GetDoOpen()) if (!GetDoOpen())
@ -93,7 +93,7 @@ void PreviewModel::UpdateSave(int saveID, int saveDate)
urlStream.str(""); urlStream.str("");
urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID << "&Start=" << (commentsPageNumber-1)*20 << "&Count=20"; urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID << "&Start=" << (commentsPageNumber-1)*20 << "&Count=20";
commentsDownload = new Download(urlStream.str()); commentsDownload = new Download(urlStream.str());
commentsDownload->AuthHeaders(format::NumberToString(Client::Ref().GetAuthUser().ID), Client::Ref().GetAuthUser().SessionID); commentsDownload->AuthHeaders(format::NumberToString(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
commentsDownload->Start(); commentsDownload->Start();
} }
} }
@ -146,7 +146,7 @@ void PreviewModel::UpdateComments(int pageNumber)
std::stringstream urlStream; std::stringstream urlStream;
urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID << "&Start=" << (commentsPageNumber-1)*20 << "&Count=20"; urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID << "&Start=" << (commentsPageNumber-1)*20 << "&Count=20";
commentsDownload = new Download(urlStream.str()); commentsDownload = new Download(urlStream.str());
commentsDownload->AuthHeaders(format::NumberToString(Client::Ref().GetAuthUser().ID).c_str(), Client::Ref().GetAuthUser().SessionID.c_str()); commentsDownload->AuthHeaders(format::NumberToString(Client::Ref().GetAuthUser().UserID).c_str(), Client::Ref().GetAuthUser().SessionID.c_str());
commentsDownload->Start(); commentsDownload->Start();
} }

View File

@ -97,7 +97,7 @@ PreviewView::PreviewView():
favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
favButton->SetIcon(IconFavourite); favButton->SetIcon(IconFavourite);
favButton->SetActionCallback(new FavAction(this)); favButton->SetActionCallback(new FavAction(this));
favButton->Enabled = Client::Ref().GetAuthUser().ID?true:false; favButton->Enabled = Client::Ref().GetAuthUser().UserID?true:false;
AddComponent(favButton); AddComponent(favButton);
class ReportPromptCallback: public TextDialogueCallback { class ReportPromptCallback: public TextDialogueCallback {
@ -125,7 +125,7 @@ PreviewView::PreviewView():
reportButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; reportButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; reportButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; reportButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
reportButton->SetIcon(IconReport); reportButton->SetIcon(IconReport);
reportButton->SetActionCallback(new ReportAction(this)); reportButton->SetActionCallback(new ReportAction(this));
reportButton->Enabled = Client::Ref().GetAuthUser().ID?true:false; reportButton->Enabled = Client::Ref().GetAuthUser().UserID?true:false;
AddComponent(reportButton); AddComponent(reportButton);
class OpenAction: public ui::ButtonAction class OpenAction: public ui::ButtonAction
@ -512,7 +512,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
{ {
authorDateLabel->SetText("\bgAuthor:\bw " + save->userName + " \bg" + dateType + " \bw" + format::UnixtimeToDateMini(save->updatedDate)); authorDateLabel->SetText("\bgAuthor:\bw " + save->userName + " \bg" + dateType + " \bw" + format::UnixtimeToDateMini(save->updatedDate));
} }
if (Client::Ref().GetAuthUser().ID && save->userName == Client::Ref().GetAuthUser().Username) if (Client::Ref().GetAuthUser().UserID && save->userName == Client::Ref().GetAuthUser().Username)
userIsAuthor = true; userIsAuthor = true;
else else
userIsAuthor = false; userIsAuthor = false;
@ -523,7 +523,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
favButton->Enabled = true; favButton->Enabled = true;
favButton->SetText("Unfav"); favButton->SetText("Unfav");
} }
else if(Client::Ref().GetAuthUser().ID) else if(Client::Ref().GetAuthUser().UserID)
{ {
favButton->Enabled = true; favButton->Enabled = true;
favButton->SetText("Fav"); favButton->SetText("Fav");
@ -687,7 +687,7 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
tempUsername = new ui::Label(ui::Point(5, currentY+3), ui::Point(Size.X-((XRES/2) + 13), 16), comments->at(i)->authorNameFormatted); tempUsername = new ui::Label(ui::Point(5, currentY+3), ui::Point(Size.X-((XRES/2) + 13), 16), comments->at(i)->authorNameFormatted);
tempUsername->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempUsername->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempUsername->Appearance.VerticalAlign = ui::Appearance::AlignBottom; tempUsername->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
if (Client::Ref().GetAuthUser().ID && Client::Ref().GetAuthUser().Username == comments->at(i)->authorName) if (Client::Ref().GetAuthUser().UserID && Client::Ref().GetAuthUser().Username == comments->at(i)->authorName)
tempUsername->SetTextColour(ui::Colour(255, 255, 100)); tempUsername->SetTextColour(ui::Colour(255, 255, 100));
else if (sender->GetSaveInfo() && sender->GetSaveInfo()->GetUserName() == comments->at(i)->authorName) else if (sender->GetSaveInfo() && sender->GetSaveInfo()->GetUserName() == comments->at(i)->authorName)
tempUsername->SetTextColour(ui::Colour(255, 100, 100)); tempUsername->SetTextColour(ui::Colour(255, 100, 100));

View File

@ -21,7 +21,7 @@ ProfileActivity::ProfileActivity(std::string username) :
doError(false), doError(false),
doErrorMessage("") doErrorMessage("")
{ {
editable = Client::Ref().GetAuthUser().ID && Client::Ref().GetAuthUser().Username == username; editable = Client::Ref().GetAuthUser().UserID && Client::Ref().GetAuthUser().Username == username;
class CloseAction: public ui::ButtonAction class CloseAction: public ui::ButtonAction

View File

@ -162,7 +162,7 @@ void SearchController::ChangeSort()
void SearchController::ShowOwn(bool show) void SearchController::ShowOwn(bool show)
{ {
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
searchModel->SetShowFavourite(false); searchModel->SetShowFavourite(false);
searchModel->SetShowOwn(show); searchModel->SetShowOwn(show);
@ -174,7 +174,7 @@ void SearchController::ShowOwn(bool show)
void SearchController::ShowFavourite(bool show) void SearchController::ShowFavourite(bool show)
{ {
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
{ {
searchModel->SetShowOwn(false); searchModel->SetShowOwn(false);
searchModel->SetShowFavourite(show); searchModel->SetShowFavourite(show);
@ -186,7 +186,7 @@ void SearchController::ShowFavourite(bool show)
void SearchController::Selected(int saveID, bool selected) void SearchController::Selected(int saveID, bool selected)
{ {
if(!Client::Ref().GetAuthUser().ID) if(!Client::Ref().GetAuthUser().UserID)
return; return;
if(selected) if(selected)

View File

@ -39,7 +39,7 @@ void * SearchModel::updateSaveListT()
std::string category = ""; std::string category = "";
if(showFavourite) if(showFavourite)
category = "Favourites"; category = "Favourites";
if(showOwn && Client::Ref().GetAuthUser().ID) if(showOwn && Client::Ref().GetAuthUser().UserID)
category = "by:"+Client::Ref().GetAuthUser().Username; category = "by:"+Client::Ref().GetAuthUser().Username;
vector<SaveInfo*> * saveList = Client::Ref().SearchSaves((currentPage-1)*20, 20, lastQuery, currentSort=="new"?"date":"votes", category, thResultCount); vector<SaveInfo*> * saveList = Client::Ref().SearchSaves((currentPage-1)*20, 20, lastQuery, currentSort=="new"?"date":"votes", category, thResultCount);

View File

@ -426,7 +426,7 @@ void SearchView::CheckAccess()
favButton->DoAction(); favButton->DoAction();
} }
if (Client::Ref().GetAuthUser().ID) if (Client::Ref().GetAuthUser().UserID)
{ {
ownButton->Enabled = true; ownButton->Enabled = true;
favButton->Enabled = true; favButton->Enabled = true;
@ -591,7 +591,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
{ {
nextButton->Enabled = true; nextButton->Enabled = true;
previousButton->Enabled = true; previousButton->Enabled = true;
if (Client::Ref().GetAuthUser().ID) if (Client::Ref().GetAuthUser().UserID)
favButton->Enabled = true; favButton->Enabled = true;
} }
if (!sender->GetSavesLoaded() || favButton->GetToggleState()) if (!sender->GetSavesLoaded() || favButton->GetToggleState())
@ -601,7 +601,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
} }
else else
{ {
if (Client::Ref().GetAuthUser().ID) if (Client::Ref().GetAuthUser().UserID)
ownButton->Enabled = true; ownButton->Enabled = true;
sortButton->Enabled = true; sortButton->Enabled = true;
} }
@ -701,7 +701,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
saves[i]); saves[i]);
saveButton->AddContextMenu(0); saveButton->AddContextMenu(0);
saveButton->SetActionCallback(new SaveOpenAction(this)); saveButton->SetActionCallback(new SaveOpenAction(this));
if(Client::Ref().GetAuthUser().ID) if(Client::Ref().GetAuthUser().UserID)
saveButton->SetSelectable(true); saveButton->SetSelectable(true);
if (saves[i]->GetUserName() == Client::Ref().GetAuthUser().Username || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator) if (saves[i]->GetUserName() == Client::Ref().GetAuthUser().Username || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator)
saveButton->SetShowVotes(true); saveButton->SetShowVotes(true);

View File

@ -57,7 +57,7 @@ TagsView::TagsView():
addButton->SetActionCallback(new AddTagAction(this)); addButton->SetActionCallback(new AddTagAction(this));
AddComponent(addButton); AddComponent(addButton);
if (!Client::Ref().GetAuthUser().ID) if (!Client::Ref().GetAuthUser().UserID)
addButton->Enabled = false; addButton->Enabled = false;
title = new ui::Label(ui::Point(5, 5), ui::Point(185, 28), "Manage tags: \bgTags are only to \nbe used to improve search results"); title = new ui::Label(ui::Point(5, 5), ui::Point(185, 28), "Manage tags: \bgTags are only to \nbe used to improve search results");

View File

@ -1463,7 +1463,7 @@ int luatpt_textwidth(lua_State* l)
int luatpt_get_name(lua_State* l) int luatpt_get_name(lua_State* l)
{ {
if (luacon_model->GetUser().ID) if (luacon_model->GetUser().UserID)
{ {
lua_pushstring(l, luacon_model->GetUser().Username.c_str()); lua_pushstring(l, luacon_model->GetUser().Username.c_str());
return 1; return 1;

View File

@ -128,6 +128,11 @@
#define REPLACE_MODE 0x1 #define REPLACE_MODE 0x1
#define SPECIFIC_DELETE 0x2 #define SPECIFIC_DELETE 0x2
#define ID(r) ((r)>>8)
#define TYP(r) ((r)&0xFF)
#define PMAP(id, typ) ((id)<<8 | ((typ)&0xFF))
#define PMAPID(id) ((id)<<8)
#ifndef SIMULATIONDATA_H #ifndef SIMULATIONDATA_H
#define SIMULATIONDATA_H #define SIMULATIONDATA_H

View File

@ -71,8 +71,8 @@ int Element_ACEL::update(UPDATE_FUNC_ARGS)
continue; continue;
if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{ {
parts[r>>8].vx *= multiplier; parts[ID(r)].vx *= multiplier;
parts[r>>8].vy *= multiplier; parts[ID(r)].vy *= multiplier;
parts[i].tmp = 1; parts[i].tmp = 1;
} }
} }

View File

@ -62,9 +62,9 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD) if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD)
{ {
sim->part_change_type(i,x,y,PT_FIRE); sim->part_change_type(i,x,y,PT_FIRE);
sim->part_change_type(r>>8,x+rx,y+ry,PT_FIRE); sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE);
parts[i].life = 4; parts[i].life = 4;
parts[r>>8].life = 4; parts[ID(r)].life = 4;
} }
else if ((r&0xFF)==PT_WTRV) else if ((r&0xFF)==PT_WTRV)
{ {
@ -72,12 +72,12 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
{ {
sim->part_change_type(i, x, y, PT_CAUS); sim->part_change_type(i, x, y, PT_CAUS);
parts[i].life = (rand()%50)+25; parts[i].life = (rand()%50)+25;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && sim->elements[r&0xFF].Hardness>(rand()%1000))&&parts[i].life>=50) else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && sim->elements[r&0xFF].Hardness>(rand()%1000))&&parts[i].life>=50)
{ {
if (sim->parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid if (sim->parts_avg(i, ID(r),PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid
{ {
float newtemp = ((60.0f-(float)sim->elements[r&0xFF].Hardness))*7.0f; float newtemp = ((60.0f-(float)sim->elements[r&0xFF].Hardness))*7.0f;
if(newtemp < 0){ if(newtemp < 0){
@ -85,7 +85,7 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
} }
parts[i].temp += newtemp; parts[i].temp += newtemp;
parts[i].life--; parts[i].life--;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
else if (parts[i].life<=50) else if (parts[i].life<=50)
@ -104,17 +104,17 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_ACID && (parts[i].life>parts[r>>8].life) && parts[i].life>0)//diffusion if ((r&0xFF)==PT_ACID && (parts[i].life>parts[ID(r)].life) && parts[i].life>0)//diffusion
{ {
int temp = parts[i].life - parts[r>>8].life; int temp = parts[i].life - parts[ID(r)].life;
if (temp==1) if (temp==1)
{ {
parts[r>>8].life++; parts[ID(r)].life++;
parts[i].life--; parts[i].life--;
} }
else if (temp>0) else if (temp>0)
{ {
parts[r>>8].life += temp/2; parts[ID(r)].life += temp/2;
parts[i].life -= temp/2; parts[i].life -= temp/2;
} }
} }

View File

@ -66,9 +66,9 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS)
return 1; return 1;
} }
if (!(rand()%10)) if (!(rand()%10))
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT); sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
else else
sim->kill_part(r>>8); sim->kill_part(ID(r));
sim->pv[y/CELL][x/CELL] -= 2.0f; sim->pv[y/CELL][x/CELL] -= 2.0f;
} }
} }

View File

@ -62,7 +62,7 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS)
{ {
sim->part_change_type(i,x,y,PT_CFLM); sim->part_change_type(i,x,y,PT_CFLM);
parts[i].life = rand()%150+50; parts[i].life = rand()%150+50;
parts[r>>8].temp = parts[i].temp = 0; parts[ID(r)].temp = parts[i].temp = 0;
sim->pv[y/CELL][x/CELL] -= 0.5; sim->pv[y/CELL][x/CELL] -= 0.5;
} }
} }

View File

@ -56,11 +56,11 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS)
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF) == PT_SPRK && parts[r>>8].life == 3) if ((r&0xFF) == PT_SPRK && parts[ID(r)].life == 3)
{ {
bool isBlackDeco = false; bool isBlackDeco = false;
int destroy = (parts[r>>8].ctype==PT_PSCN) ? 1 : 0; int destroy = (parts[ID(r)].ctype==PT_PSCN) ? 1 : 0;
int nostop = (parts[r>>8].ctype==PT_INST) ? 1 : 0; int nostop = (parts[ID(r)].ctype==PT_INST) ? 1 : 0;
int colored = 0, rt; int colored = 0, rt;
for (int docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) for (int docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi)
{ {
@ -69,7 +69,7 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS)
r = pmap[y+nyi+nyy][x+nxi+nxx]; r = pmap[y+nyi+nyy][x+nxi+nxx];
rt = r & 0xFF; rt = r & 0xFF;
r = r >> 8; r = ID(r);
if (!rt) if (!rt)
{ {
int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY);

View File

@ -76,7 +76,7 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
{ {
parts[i].ctype = rt; parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA) if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype; parts[i].tmp = parts[ID(r)].ctype;
} }
} }
} }

View File

@ -62,10 +62,10 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)!=PT_BIZR && (r&0xFF)!=PT_BIZRG && (r&0xFF)!=PT_BIZRS) if ((r&0xFF)!=PT_BIZR && (r&0xFF)!=PT_BIZRG && (r&0xFF)!=PT_BIZRS)
{ {
tr = (parts[r>>8].dcolour>>16)&0xFF; tr = (parts[ID(r)].dcolour>>16)&0xFF;
tg = (parts[r>>8].dcolour>>8)&0xFF; tg = (parts[ID(r)].dcolour>>8)&0xFF;
tb = (parts[r>>8].dcolour)&0xFF; tb = (parts[ID(r)].dcolour)&0xFF;
ta = (parts[r>>8].dcolour>>24)&0xFF; ta = (parts[ID(r)].dcolour>>24)&0xFF;
mr = (parts[i].dcolour>>16)&0xFF; mr = (parts[i].dcolour>>16)&0xFF;
mg = (parts[i].dcolour>>8)&0xFF; mg = (parts[i].dcolour>>8)&0xFF;
@ -77,7 +77,7 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS)
nb = (tb*BLEND) + (mb*(1 - BLEND)); nb = (tb*BLEND) + (mb*(1 - BLEND));
na = (ta*BLEND) + (ma*(1 - BLEND)); na = (ta*BLEND) + (ma*(1 - BLEND));
parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; parts[ID(r)].dcolour = nr<<16 | ng<<8 | nb | na<<24;
} }
} }
} }

View File

@ -60,8 +60,8 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS)
continue; continue;
if (((r&0xFF)==PT_METL || (r&0xFF)==PT_IRON) && !(rand()%100)) if (((r&0xFF)==PT_METL || (r&0xFF)==PT_IRON) && !(rand()%100))
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_BMTL); sim->part_change_type(ID(r),x+rx,y+ry,PT_BMTL);
parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
} }
} }
} }

View File

@ -71,13 +71,13 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS)
if ((r&0xFF)==PT_WATR) if ((r&0xFF)==PT_WATR)
{ {
if (!(rand()%30)) if (!(rand()%30))
sim->part_change_type(r>>8,x+rx,y+ry,PT_FOG); sim->part_change_type(ID(r),x+rx,y+ry,PT_FOG);
} }
else if ((r&0xFF)==PT_O2) else if ((r&0xFF)==PT_O2)
{ {
if (!(rand()%9)) if (!(rand()%9))
{ {
sim->kill_part(r>>8); sim->kill_part(ID(r));
sim->part_change_type(i,x,y,PT_WATR); sim->part_change_type(i,x,y,PT_WATR);
sim->pv[y/CELL][x/CELL] += 4.0; sim->pv[y/CELL][x/CELL] += 4.0;
} }

View File

@ -64,12 +64,12 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS)
{ {
if(rand()%2) if(rand()%2)
{ {
sim->create_part(r>>8, x+rx, y+ry, PT_THRM); sim->create_part(ID(r), x+rx, y+ry, PT_THRM);
} }
else else
sim->create_part(i, x, y, PT_THRM); sim->create_part(i, x, y, PT_THRM);
//part_change_type(r>>8,x+rx,y+ry,PT_BMTL); //part_change_type(ID(r),x+rx,y+ry,PT_BMTL);
//parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; //parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
} }
} }
} }

View File

@ -56,13 +56,13 @@ int Element_BTRY::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
rt = (r&0xFF); rt = (r&0xFF);
if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL) if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
{ {
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0) if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
{ {
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = rt; parts[ID(r)].ctype = rt;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
} }
} }
} }

View File

@ -56,12 +56,12 @@ int Element_C5::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100 && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10)) || (r&0xFF)==PT_CFLM) if (((r&0xFF)!=PT_C5 && parts[ID(r)].temp<100 && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[ID(r)].life==10)) || (r&0xFF)==PT_CFLM)
{ {
if (!(rand()%6)) if (!(rand()%6))
{ {
sim->part_change_type(i,x,y,PT_CFLM); sim->part_change_type(i,x,y,PT_CFLM);
parts[r>>8].temp = parts[i].temp = 0; parts[ID(r)].temp = parts[i].temp = 0;
parts[i].life = rand()%150+50; parts[i].life = rand()%150+50;
sim->pv[y/CELL][x/CELL] += 1.5; sim->pv[y/CELL][x/CELL] += 1.5;
} }

View File

@ -58,7 +58,7 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS)
{ {
if (sim->pv[(y+ry)/CELL][(x+rx)/CELL] > 3) if (sim->pv[(y+ry)/CELL][(x+rx)/CELL] > 3)
{ {
sim->part_change_type(r>>8, x+rx, y+ry, PT_RFRG); sim->part_change_type(ID(r), x+rx, y+ry, PT_RFRG);
sim->part_change_type(i, x, y, PT_RFRG); sim->part_change_type(i, x, y, PT_RFRG);
} }
} }
@ -67,14 +67,14 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS)
if (((r&0xFF) != PT_CLNE && (r&0xFF) != PT_PCLN && sim->elements[r&0xFF].Hardness > (rand()%1000)) && parts[i].life >= 50) if (((r&0xFF) != PT_CLNE && (r&0xFF) != PT_PCLN && sim->elements[r&0xFF].Hardness > (rand()%1000)) && parts[i].life >= 50)
{ {
// GLAS protects stuff from acid // GLAS protects stuff from acid
if (sim->parts_avg(i, r>>8,PT_GLAS) != PT_GLAS) if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS)
{ {
float newtemp = ((60.0f - (float)sim->elements[r&0xFF].Hardness)) * 7.0f; float newtemp = ((60.0f - (float)sim->elements[r&0xFF].Hardness)) * 7.0f;
if (newtemp < 0) if (newtemp < 0)
newtemp = 0; newtemp = 0;
parts[i].temp += newtemp; parts[i].temp += newtemp;
parts[i].life--; parts[i].life--;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
else if (parts[i].life <= 50) else if (parts[i].life <= 50)

View File

@ -99,18 +99,18 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
{ {
if(!parts[i].tmp) if(!parts[i].tmp)
{ {
if (parts[r>>8].tmp) if (parts[ID(r)].tmp)
{ {
parts[i].tmp = parts[r>>8].tmp; parts[i].tmp = parts[ID(r)].tmp;
if((r>>8)>i) //If the other particle hasn't been life updated if((ID(r))>i) //If the other particle hasn't been life updated
parts[i].tmp--; parts[i].tmp--;
} }
} }
else if(!parts[r>>8].tmp) else if(!parts[ID(r)].tmp)
{ {
parts[r>>8].tmp = parts[i].tmp; parts[ID(r)].tmp = parts[i].tmp;
if((r>>8)>i) //If the other particle hasn't been life updated if((ID(r))>i) //If the other particle hasn't been life updated
parts[r>>8].tmp++; parts[ID(r)].tmp++;
} }
} }
else if ((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) else if ((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD)
@ -122,8 +122,8 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
parts[i].ctype = PT_WATR; parts[i].ctype = PT_WATR;
} }
} }
else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ else if ((r&0xFF)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){
sim->kill_part(r>>8); sim->kill_part(ID(r));
if(!(rand()%50)){ if(!(rand()%50)){
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;

View File

@ -67,7 +67,7 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS)
{ {
parts[i].ctype = rt; parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA) if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype; parts[i].tmp = parts[ID(r)].ctype;
} }
} }
} }

View File

@ -62,13 +62,13 @@ int Element_CLST::update(UPDATE_FUNC_ARGS)
if (!(rand()%1500)) if (!(rand()%1500))
{ {
sim->create_part(i, x, y, PT_PSTS); sim->create_part(i, x, y, PT_PSTS);
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
else if ((r&0xFF)==PT_NITR) else if ((r&0xFF)==PT_NITR)
{ {
sim->create_part(i, x, y, PT_BANG); sim->create_part(i, x, y, PT_BANG);
sim->create_part(r>>8, x+rx, y+ry, PT_BANG); sim->create_part(ID(r), x+rx, y+ry, PT_BANG);
} }
else if ((r&0xFF)==PT_CLST) else if ((r&0xFF)==PT_CLST)
{ {

View File

@ -63,7 +63,7 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
continue; continue;
} }
if ((r&0xFF)==PT_FIRE){ if ((r&0xFF)==PT_FIRE){
sim->kill_part(r>>8); sim->kill_part(ID(r));
if(!(rand()%30)){ if(!(rand()%30)){
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
@ -71,7 +71,7 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
} }
else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%50)) else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%50))
{ {
sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW); sim->part_change_type(ID(r), x+rx, y+ry, PT_CBNW);
if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet
{ {
sim->create_part(i, x, y, PT_WATR); sim->create_part(i, x, y, PT_WATR);

View File

@ -67,7 +67,7 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
{ {
parts[i].ctype = r&0xFF; parts[i].ctype = r&0xFF;
if ((r&0xFF)==PT_LIFE) if ((r&0xFF)==PT_LIFE)
parts[i].ctype |= (parts[r>>8].ctype << 8); parts[i].ctype |= (parts[ID(r)].ctype << 8);
} }
} }
} }
@ -85,7 +85,7 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
continue; continue;
if((r&0xFF)!=PT_CONV && (r&0xFF)!=PT_DMND && (r&0xFF)!=ctype) if((r&0xFF)!=PT_CONV && (r&0xFF)!=PT_DMND && (r&0xFF)!=ctype)
{ {
sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype&0xFF, parts[i].ctype>>8); sim->create_part(ID(r), x+rx, y+ry, parts[i].ctype&0xFF, parts[i].ctype>>8);
} }
} }
} }

View File

@ -63,7 +63,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
if ((r&0xFF)!=PT_CRAY && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_INST && (r&0xFF)!=PT_METL && (r&0xFF)!=PT_SPRK && (r&0xFF)<PT_NUM) if ((r&0xFF)!=PT_CRAY && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_INST && (r&0xFF)!=PT_METL && (r&0xFF)!=PT_SPRK && (r&0xFF)<PT_NUM)
{ {
parts[i].ctype = r&0xFF; parts[i].ctype = r&0xFF;
parts[i].temp = parts[r>>8].temp; parts[i].temp = parts[ID(r)].temp;
} }
} }
} }
@ -76,11 +76,11 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) { //spark found, start creating if ((r&0xFF)==PT_SPRK && parts[ID(r)].life==3) { //spark found, start creating
unsigned int colored = 0; unsigned int colored = 0;
bool destroy = parts[r>>8].ctype==PT_PSCN; bool destroy = parts[ID(r)].ctype==PT_PSCN;
bool nostop = parts[r>>8].ctype==PT_INST; bool nostop = parts[ID(r)].ctype==PT_INST;
bool createSpark = (parts[r>>8].ctype==PT_INWR); bool createSpark = (parts[ID(r)].ctype==PT_INWR);
int partsRemaining = 255; int partsRemaining = 255;
if (parts[i].tmp) //how far it shoots if (parts[i].tmp) //how far it shoots
partsRemaining = parts[i].tmp; partsRemaining = parts[i].tmp;
@ -103,19 +103,19 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
docontinue = 0; docontinue = 0;
} }
} else if ((r&0xFF)==PT_FILT) { // get color if passed through FILT } else if ((r&0xFF)==PT_FILT) { // get color if passed through FILT
if (parts[r>>8].dcolour == 0xFF000000) if (parts[ID(r)].dcolour == 0xFF000000)
colored = 0xFF000000; colored = 0xFF000000;
else if (parts[r>>8].tmp==0) else if (parts[ID(r)].tmp==0)
{ {
colored = wavelengthToDecoColour(Element_FILT::getWavelengths(&parts[r>>8])); colored = wavelengthToDecoColour(Element_FILT::getWavelengths(&parts[ID(r)]));
} }
else if (colored==0xFF000000) else if (colored==0xFF000000)
colored = 0; colored = 0;
parts[r>>8].life = 4; parts[ID(r)].life = 4;
} else if ((r&0xFF) == PT_CRAY || nostop) { } else if ((r&0xFF) == PT_CRAY || nostop) {
docontinue = 1; docontinue = 1;
} else if(destroy && r && ((r&0xFF) != PT_DMND)) { } else if(destroy && r && ((r&0xFF) != PT_DMND)) {
sim->kill_part(r>>8); sim->kill_part(ID(r));
if(!--partsRemaining) if(!--partsRemaining)
docontinue = 0; docontinue = 0;
} }

View File

@ -66,8 +66,8 @@ int Element_DCEL::update(UPDATE_FUNC_ARGS)
continue; continue;
if (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) if (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{ {
parts[r>>8].vx *= multiplier; parts[ID(r)].vx *= multiplier;
parts[r>>8].vy *= multiplier; parts[ID(r)].vy *= multiplier;
parts[i].tmp = 1; parts[i].tmp = 1;
} }
} }

View File

@ -64,25 +64,25 @@ int Element_DEST::update(UPDATE_FUNC_ARGS)
sim->pv[y/CELL][x/CELL]+=20.0f; sim->pv[y/CELL][x/CELL]+=20.0f;
if (rand()%2) if (rand()%2)
{ {
sim->create_part(r>>8, x+rx, y+ry, PT_NEUT); sim->create_part(ID(r), x+rx, y+ry, PT_NEUT);
parts[r>>8].temp = MAX_TEMP; parts[ID(r)].temp = MAX_TEMP;
sim->pv[y/CELL][x/CELL] += 10.0f; sim->pv[y/CELL][x/CELL] += 10.0f;
parts[i].life-=4; parts[i].life-=4;
} }
} }
else if ((r&0xFF)==PT_INSL) else if ((r&0xFF)==PT_INSL)
{ {
sim->create_part(r>>8, x+rx, y+ry, PT_PLSM); sim->create_part(ID(r), x+rx, y+ry, PT_PLSM);
} }
else if (!(rand()%3)) else if (!(rand()%3))
{ {
sim->kill_part(r>>8); sim->kill_part(ID(r));
parts[i].life -= 4*((sim->elements[r&0xFF].Properties&TYPE_SOLID)?3:1); parts[i].life -= 4*((sim->elements[r&0xFF].Properties&TYPE_SOLID)?3:1);
if (parts[i].life<=0) if (parts[i].life<=0)
parts[i].life=1; parts[i].life=1;
} }
else if (sim->elements[r&0xFF].HeatConduct) else if (sim->elements[r&0xFF].HeatConduct)
parts[r>>8].temp = MAX_TEMP; parts[ID(r)].temp = MAX_TEMP;
parts[i].temp=MAX_TEMP; parts[i].temp=MAX_TEMP;
sim->pv[y/CELL][x/CELL]+=80.0f; sim->pv[y/CELL][x/CELL]+=80.0f;
return 0; return 0;

View File

@ -69,10 +69,10 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS)
{ {
// If neighbour life+1 fits in the free capacity for this particle, absorb neighbour // If neighbour life+1 fits in the free capacity for this particle, absorb neighbour
// Condition is written in this way so that large neighbour life values don't cause integer overflow // Condition is written in this way so that large neighbour life values don't cause integer overflow
if (parts[r>>8].life <= maxlife - parts[i].life - 1) if (parts[ID(r)].life <= maxlife - parts[i].life - 1)
{ {
parts[i].life += parts[r>>8].life + 1; parts[i].life += parts[ID(r)].life + 1;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
} }
@ -105,17 +105,17 @@ trade:
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_DEUT&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion if ((r&0xFF)==PT_DEUT&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion
{ {
int temp = parts[i].life - parts[r>>8].life; int temp = parts[i].life - parts[ID(r)].life;
if (temp ==1) if (temp ==1)
{ {
parts[r>>8].life ++; parts[ID(r)].life ++;
parts[i].life --; parts[i].life --;
} }
else if (temp>0) else if (temp>0)
{ {
parts[r>>8].life += temp/2; parts[ID(r)].life += temp/2;
parts[i].life -= temp/2; parts[i].life -= temp/2;
} }
} }

View File

@ -59,9 +59,9 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r || sim->parts_avg(r>>8, i,PT_INSL)==PT_INSL) if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL)
continue; continue;
if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN) if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[ID(r)].life>0 && parts[ID(r)].life<4 && parts[ID(r)].ctype==PT_PSCN)
{ {
parts[i].life = (int)(parts[i].temp-273.15f+0.5f); parts[i].life = (int)(parts[i].temp-273.15f+0.5f);
} }
@ -69,18 +69,18 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
{ {
if (!parts[i].life) if (!parts[i].life)
{ {
if (parts[r>>8].life) if (parts[ID(r)].life)
{ {
parts[i].life = parts[r>>8].life; parts[i].life = parts[ID(r)].life;
if((r>>8)>i) //If the other particle hasn't been life updated if((ID(r))>i) //If the other particle hasn't been life updated
parts[i].life--; parts[i].life--;
} }
} }
else if (!parts[r>>8].life) else if (!parts[ID(r)].life)
{ {
parts[r>>8].life = parts[i].life; parts[ID(r)].life = parts[i].life;
if((r>>8)>i) //If the other particle hasn't been life updated if((ID(r))>i) //If the other particle hasn't been life updated
parts[r>>8].life++; parts[ID(r)].life++;
} }
} }
else if((r&0xFF)==PT_NSCN && oldl==1) else if((r&0xFF)==PT_NSCN && oldl==1)

View File

@ -68,12 +68,12 @@ int Element_DRAY::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if ((r&0xFF) == PT_SPRK && parts[r>>8].life == 3) //spark found, start creating if ((r&0xFF) == PT_SPRK && parts[ID(r)].life == 3) //spark found, start creating
{ {
bool overwrite = parts[r>>8].ctype == PT_PSCN; bool overwrite = parts[ID(r)].ctype == PT_PSCN;
int partsRemaining = copyLength, xCopyTo, yCopyTo; //positions where the line will start being copied at int partsRemaining = copyLength, xCopyTo, yCopyTo; //positions where the line will start being copied at
if (parts[r>>8].ctype == PT_INWR && rx && ry) // INWR doesn't spark from diagonals if (parts[ID(r)].ctype == PT_INWR && rx && ry) // INWR doesn't spark from diagonals
continue; continue;
//figure out where the copying will start/end //figure out where the copying will start/end

View File

@ -61,7 +61,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 DSTW to SLTW before SALT turns into SLTW // on average, convert 3 DSTW to SLTW before SALT turns into SLTW
if (!(rand()%3)) if (!(rand()%3))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
} }
break; break;
case PT_SLTW: case PT_SLTW:
@ -85,7 +85,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
} }
break; break;
case PT_FIRE: case PT_FIRE:
sim->kill_part(r>>8); sim->kill_part(ID(r));
if(!(rand()%30)){ if(!(rand()%30)){
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;

View File

@ -60,13 +60,13 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = r&0xFF;
if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL) if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
{ {
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0) if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
{ {
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = rt; parts[ID(r)].ctype = rt;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
} }
} }
} }
@ -82,12 +82,12 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if(!r) if(!r)
continue; continue;
if ((r&0xFF) == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[r>>8].ctype || !parts[i].tmp)) if ((r&0xFF) == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[ID(r)].ctype || !parts[i].tmp))
parts[i].life = 1; parts[i].life = 1;
if ((r&0xFF) == PT_PHOT || ((r&0xFF) == PT_BRAY && parts[r>>8].tmp!=2)) if ((r&0xFF) == PT_PHOT || ((r&0xFF) == PT_BRAY && parts[ID(r)].tmp!=2))
{ {
setFilt = true; setFilt = true;
photonWl = parts[r>>8].ctype; photonWl = parts[ID(r)].ctype;
} }
} }
if (setFilt) if (setFilt)
@ -104,7 +104,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
ny = y+ry; ny = y+ry;
while ((r&0xFF)==PT_FILT) while ((r&0xFF)==PT_FILT)
{ {
parts[r>>8].ctype = photonWl; parts[ID(r)].ctype = photonWl;
nx += rx; nx += rx;
ny += ry; ny += ry;
if (nx<0 || ny<0 || nx>=XRES || ny>=YRES) if (nx<0 || ny<0 || nx>=XRES || ny>=YRES)

View File

@ -76,36 +76,36 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
case PT_LCRY: case PT_LCRY:
parts[r>>8].tmp2 = 5+rand()%5; parts[ID(r)].tmp2 = 5+rand()%5;
break; break;
case PT_WATR: case PT_WATR:
case PT_DSTW: case PT_DSTW:
case PT_SLTW: case PT_SLTW:
case PT_CBNW: case PT_CBNW:
if(!(rand()%3)) if(!(rand()%3))
sim->create_part(r>>8, x+rx, y+ry, PT_O2); sim->create_part(ID(r), x+rx, y+ry, PT_O2);
else else
sim->create_part(r>>8, x+rx, y+ry, PT_H2); sim->create_part(ID(r), x+rx, y+ry, PT_H2);
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
case PT_PROT: // this is the correct reaction, not NEUT, but leaving NEUT in anyway case PT_PROT: // this is the correct reaction, not NEUT, but leaving NEUT in anyway
if (parts[r>>8].tmp2 & 0x1) if (parts[ID(r)].tmp2 & 0x1)
break; break;
case PT_NEUT: case PT_NEUT:
sim->part_change_type(r>>8, x+rx, y+ry, PT_H2); sim->part_change_type(ID(r), x+rx, y+ry, PT_H2);
parts[r>>8].life = 0; parts[ID(r)].life = 0;
parts[r>>8].ctype = 0; parts[ID(r)].ctype = 0;
sim->kill_part(i); sim->kill_part(i);
break; break;
case PT_DEUT: case PT_DEUT:
if(parts[r>>8].life < 6000) if(parts[ID(r)].life < 6000)
parts[r>>8].life += 1; parts[ID(r)].life += 1;
parts[r>>8].temp = 0; parts[ID(r)].temp = 0;
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
case PT_EXOT: case PT_EXOT:
parts[r>>8].tmp2 += 5; parts[ID(r)].tmp2 += 5;
parts[r>>8].life = 1000; parts[ID(r)].life = 1000;
break; break;
case PT_NONE: //seems to speed up ELEC even if it isn't used case PT_NONE: //seems to speed up ELEC even if it isn't used
break; break;

View File

@ -119,10 +119,10 @@ int Element_ETRD::nearestSparkablePart(Simulation *sim, int targetId)
if (sim->InBounds(checkPos.X, checkPos.Y) && checkDistance <= foundDistance) if (sim->InBounds(checkPos.X, checkPos.Y) && checkDistance <= foundDistance)
{ {
int r = sim->pmap[checkPos.Y][checkPos.X]; int r = sim->pmap[checkPos.Y][checkPos.X];
if (r && (r&0xFF) == PT_ETRD && !parts[r>>8].life && r>>8 != targetId && checkDistance < foundDistance) if (r && (r&0xFF) == PT_ETRD && !parts[ID(r)].life && ID(r) != targetId && checkDistance < foundDistance)
{ {
foundDistance = checkDistance; foundDistance = checkDistance;
foundI = r>>8; foundI = ID(r);
} }
} }
} }

View File

@ -59,32 +59,32 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
rt = r&0xFF; rt = r&0xFF;
if (rt == PT_WARP) if (rt == PT_WARP)
{ {
if (parts[r>>8].tmp2>2000 && !(rand()%100)) if (parts[ID(r)].tmp2>2000 && !(rand()%100))
{ {
parts[i].tmp2 += 100; parts[i].tmp2 += 100;
} }
} }
else if (rt == PT_EXOT) else if (rt == PT_EXOT)
{ {
if (parts[r>>8].ctype == PT_PROT) if (parts[ID(r)].ctype == PT_PROT)
parts[i].ctype = PT_PROT; parts[i].ctype = PT_PROT;
if (parts[r>>8].life == 1500 && !(rand()%1000)) if (parts[ID(r)].life == 1500 && !(rand()%1000))
parts[i].life = 1500; parts[i].life = 1500;
} }
else if (rt == PT_LAVA) else if (rt == PT_LAVA)
{ {
//turn molten TTAN or molten GOLD to molten VIBR //turn molten TTAN or molten GOLD to molten VIBR
if (parts[r>>8].ctype == PT_TTAN || parts[r>>8].ctype == PT_GOLD) if (parts[ID(r)].ctype == PT_TTAN || parts[ID(r)].ctype == PT_GOLD)
{ {
if (!(rand()%10)) if (!(rand()%10))
{ {
parts[r>>8].ctype = PT_VIBR; parts[ID(r)].ctype = PT_VIBR;
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
} }
} }
//molten VIBR will kill the leftover EXOT though, so the VIBR isn't killed later //molten VIBR will kill the leftover EXOT though, so the VIBR isn't killed later
else if (parts[r>>8].ctype == PT_VIBR) else if (parts[ID(r)].ctype == PT_VIBR)
{ {
if (!(rand()%1000)) if (!(rand()%1000))
{ {
@ -138,18 +138,18 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_EXOT && (parts[i].tmp2 > parts[r>>8].tmp2) && parts[r>>8].tmp2 >= 0) //diffusion if ((r&0xFF)==PT_EXOT && (parts[i].tmp2 > parts[ID(r)].tmp2) && parts[ID(r)].tmp2 >= 0) //diffusion
{ {
tym = parts[i].tmp2 - parts[r>>8].tmp2; tym = parts[i].tmp2 - parts[ID(r)].tmp2;
if (tym == 1) if (tym == 1)
{ {
parts[r>>8].tmp2++; parts[ID(r)].tmp2++;
parts[i].tmp2--; parts[i].tmp2--;
break; break;
} }
if (tym > 0) if (tym > 0)
{ {
parts[r>>8].tmp2 += tym/2; parts[ID(r)].tmp2 += tym/2;
parts[i].tmp2 -= tym/2; parts[i].tmp2 -= tym/2;
break; break;
} }

View File

@ -102,13 +102,13 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000)) if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000))
{ {
sim->part_change_type(i,x,y,PT_WATR); sim->part_change_type(i,x,y,PT_WATR);
sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);
} }
if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000)) if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000))
{ {
sim->part_change_type(i,x,y,PT_WATR); sim->part_change_type(i,x,y,PT_WATR);
if (1>(rand()%1000)) if (1>(rand()%1000))
sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);
} }
} }
} }
@ -169,7 +169,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
{ {
sim->part_change_type(i,x,y,PT_ICEI); sim->part_change_type(i,x,y,PT_ICEI);
sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
} }
} }
} }
@ -184,7 +184,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
{ {
sim->part_change_type(i,x,y,PT_ICEI); sim->part_change_type(i,x,y,PT_ICEI);
sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
} }
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000)) if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000))
sim->part_change_type(i,x,y,PT_WATR); sim->part_change_type(i,x,y,PT_WATR);

View File

@ -99,16 +99,16 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
if (rt==PT_THRM && (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA)) if (rt==PT_THRM && (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA))
{ {
if (!(rand()%500)) { if (!(rand()%500)) {
sim->part_change_type(r>>8,x+rx,y+ry,PT_LAVA); sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA);
parts[r>>8].ctype = PT_BMTL; parts[ID(r)].ctype = PT_BMTL;
parts[r>>8].temp = 3500.0f; parts[ID(r)].temp = 3500.0f;
sim->pv[(y+ry)/CELL][(x+rx)/CELL] += 50.0f; sim->pv[(y+ry)/CELL][(x+rx)/CELL] += 50.0f;
} else { } else {
sim->part_change_type(r>>8,x+rx,y+ry,PT_LAVA); sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA);
parts[r>>8].life = 400; parts[ID(r)].life = 400;
parts[r>>8].ctype = PT_THRM; parts[ID(r)].ctype = PT_THRM;
parts[r>>8].temp = 3500.0f; parts[ID(r)].temp = 3500.0f;
parts[r>>8].tmp = 20; parts[ID(r)].tmp = 20;
} }
continue; continue;
} }
@ -117,15 +117,15 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
{ {
if ((t==PT_FIRE || t==PT_PLSM)) if ((t==PT_FIRE || t==PT_PLSM))
{ {
if (parts[r>>8].life>100 && !(rand()%500)) { if (parts[ID(r)].life>100 && !(rand()%500)) {
parts[r>>8].life = 99; parts[ID(r)].life = 99;
} }
} }
else if (t==PT_LAVA) else if (t==PT_LAVA)
{ {
if (parts[i].ctype == PT_IRON && !(rand()%500)) { if (parts[i].ctype == PT_IRON && !(rand()%500)) {
parts[i].ctype = PT_METL; parts[i].ctype = PT_METL;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
} }
@ -133,21 +133,21 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
if (t == PT_LAVA) if (t == PT_LAVA)
{ {
// LAVA(CLST) + LAVA(PQRT) + high enough temp = LAVA(CRMC) + LAVA(CRMC) // LAVA(CLST) + LAVA(PQRT) + high enough temp = LAVA(CRMC) + LAVA(CRMC)
if (parts[i].ctype == PT_QRTZ && rt == PT_LAVA && parts[r>>8].ctype == PT_CLST) if (parts[i].ctype == PT_QRTZ && rt == PT_LAVA && parts[ID(r)].ctype == PT_CLST)
{ {
float pres = std::max(sim->pv[y/CELL][x/CELL]*10.0f, 0.0f); float pres = std::max(sim->pv[y/CELL][x/CELL]*10.0f, 0.0f);
if (parts[i].temp >= pres+sim->elements[PT_CRMC].HighTemperature+50.0f) if (parts[i].temp >= pres+sim->elements[PT_CRMC].HighTemperature+50.0f)
{ {
parts[i].ctype = PT_CRMC; parts[i].ctype = PT_CRMC;
parts[r>>8].ctype = PT_CRMC; parts[ID(r)].ctype = PT_CRMC;
} }
} }
else if (rt == PT_HEAC && parts[i].ctype == PT_HEAC) else if (rt == PT_HEAC && parts[i].ctype == PT_HEAC)
{ {
if (parts[r>>8].temp > sim->elements[PT_HEAC].HighTemperature && rand()%200) if (parts[ID(r)].temp > sim->elements[PT_HEAC].HighTemperature && rand()%200)
{ {
sim->part_change_type(r>>8, x+rx, y+ry, PT_LAVA); sim->part_change_type(ID(r), x+rx, y+ry, PT_LAVA);
parts[r>>8].ctype = PT_HEAC; parts[ID(r)].ctype = PT_HEAC;
} }
} }
} }
@ -157,12 +157,12 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
//exceptions, t is the thing causing the spark and rt is what's burning //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_SPRK || (rt != PT_RBDM && rt != PT_LRBD && rt != PT_INSL)) &&
(t != PT_PHOT || rt != PT_INSL) && (t != PT_PHOT || rt != PT_INSL) &&
(rt != PT_SPNG || parts[r>>8].life == 0)) (rt != PT_SPNG || parts[ID(r)].life == 0))
{ {
sim->part_change_type(r>>8, x+rx, y+ry, PT_FIRE); sim->part_change_type(ID(r), x+rx, y+ry, PT_FIRE);
parts[r>>8].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP); parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP);
parts[r>>8].life = rand()%80+180; parts[ID(r)].life = rand()%80+180;
parts[r>>8].tmp = parts[r>>8].ctype = 0; parts[ID(r)].tmp = parts[ID(r)].ctype = 0;
if (sim->elements[rt].Explosive) if (sim->elements[rt].Explosive)
sim->pv[y/CELL][x/CELL] += 0.25f * CFDS; sim->pv[y/CELL][x/CELL] += 0.25f * CFDS;
} }
@ -193,13 +193,13 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
if (t!=PT_LAVA || parts[i].life>0) if (t!=PT_LAVA || parts[i].life>0)
{ {
if (rt==PT_BRMT) if (rt==PT_BRMT)
parts[r>>8].ctype = PT_BMTL; parts[ID(r)].ctype = PT_BMTL;
else if (rt==PT_SAND) else if (rt==PT_SAND)
parts[r>>8].ctype = PT_GLAS; parts[ID(r)].ctype = PT_GLAS;
else else
parts[r>>8].ctype = rt; parts[ID(r)].ctype = rt;
sim->part_change_type(r>>8,x+rx,y+ry,PT_LAVA); sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA);
parts[r>>8].life = rand()%120+240; parts[ID(r)].life = rand()%120+240;
} }
else else
{ {
@ -211,7 +211,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
} }
if (rt==PT_ICEI || rt==PT_SNOW) if (rt==PT_ICEI || rt==PT_SNOW)
{ {
sim->part_change_type(r>>8, x+rx, y+ry, PT_WATR); sim->part_change_type(ID(r), x+rx, y+ry, PT_WATR);
if (t==PT_FIRE) if (t==PT_FIRE)
{ {
sim->kill_part(i); sim->kill_part(i);
@ -225,7 +225,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
} }
if (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW) if (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW)
{ {
sim->kill_part(r>>8); sim->kill_part(ID(r));
if (t==PT_FIRE) if (t==PT_FIRE)
{ {
sim->kill_part(i); sim->kill_part(i);

View File

@ -69,8 +69,8 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
r = sim->photons[y+nyi+nyy][x+nxi+nxx]; r = sim->photons[y+nyi+nyy][x+nxi+nxx];
if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){ if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){
parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vx += nxi*((parts[i].temp-273.15)/10.0f);
parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vy += nyi*((parts[i].temp-273.15)/10.0f);
} }
} }
} }

View File

@ -57,7 +57,7 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_WATR && !(rand()%14)) if ((r&0xFF)==PT_WATR && !(rand()%14))
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW); sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
} }
} }
if ((parts[i].life==0 && !(rand()%192)) || (100-(parts[i].life))>rand()%50000 ) if ((parts[i].life==0 && !(rand()%192)) || (100-(parts[i].life))>rand()%50000 )

View File

@ -57,8 +57,8 @@ int Element_FRZZ::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_WATR && !(rand()%20)) if ((r&0xFF)==PT_WATR && !(rand()%20))
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW); sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
parts[r>>8].life = 100; parts[ID(r)].life = 100;
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
} }

View File

@ -72,14 +72,14 @@ int Element_GEL::update(UPDATE_FUNC_ARGS)
if (parts[i].tmp<100 && 500>rand()%absorbChanceDenom) if (parts[i].tmp<100 && 500>rand()%absorbChanceDenom)
{ {
parts[i].tmp++; parts[i].tmp++;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
break; break;
case PT_PSTE: case PT_PSTE:
if (parts[i].tmp<100 && 20>rand()%absorbChanceDenom) if (parts[i].tmp<100 && 20>rand()%absorbChanceDenom)
{ {
parts[i].tmp++; parts[i].tmp++;
sim->create_part(r>>8, x+rx, y+ry, PT_CLST); sim->create_part(ID(r), x+rx, y+ry, PT_CLST);
} }
break; break;
case PT_SLTW: case PT_SLTW:
@ -87,37 +87,37 @@ int Element_GEL::update(UPDATE_FUNC_ARGS)
{ {
parts[i].tmp++; parts[i].tmp++;
if (rand()%4) if (rand()%4)
sim->kill_part(r>>8); sim->kill_part(ID(r));
else else
sim->part_change_type(r>>8, x+rx, y+ry, PT_SALT); sim->part_change_type(ID(r), x+rx, y+ry, PT_SALT);
} }
break; break;
case PT_CBNW: case PT_CBNW:
if (parts[i].tmp<100 && 100>rand()%absorbChanceDenom) if (parts[i].tmp<100 && 100>rand()%absorbChanceDenom)
{ {
parts[i].tmp++; parts[i].tmp++;
sim->part_change_type(r>>8, x+rx, y+ry, PT_CO2); sim->part_change_type(ID(r), x+rx, y+ry, PT_CO2);
} }
break; break;
case PT_SPNG: case PT_SPNG:
// Concentration diffusion // Concentration diffusion
if (parts[r>>8].life>0 && parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp)) if (parts[ID(r)].life>0 && parts[i].tmp<100 && ((parts[ID(r)].life+1)>parts[i].tmp))
{ {
// SPNG -> GEL // SPNG -> GEL
parts[r>>8].life--; parts[ID(r)].life--;
parts[i].tmp++; parts[i].tmp++;
} }
else if (parts[i].tmp>0 && (parts[r>>8].life+1)<parts[i].tmp) else if (parts[i].tmp>0 && (parts[ID(r)].life+1)<parts[i].tmp)
{ {
// SPNG <- GEL (saturation limit of SPNG is ignored here) // SPNG <- GEL (saturation limit of SPNG is ignored here)
parts[r>>8].life++; parts[ID(r)].life++;
parts[i].tmp--; parts[i].tmp--;
} }
break; break;
case PT_GEL: case PT_GEL:
if ((parts[r>>8].tmp+1)<parts[i].tmp) if ((parts[ID(r)].tmp+1)<parts[i].tmp)
{ {
parts[r>>8].tmp++; parts[ID(r)].tmp++;
parts[i].tmp--; parts[i].tmp--;
} }
gel = true; gel = true;
@ -126,8 +126,8 @@ int Element_GEL::update(UPDATE_FUNC_ARGS)
break; break;
} }
float dx, dy; float dx, dy;
dx = parts[i].x - parts[r>>8].x; dx = parts[i].x - parts[ID(r)].x;
dy = parts[i].y - parts[r>>8].y; dy = parts[i].y - parts[ID(r)].y;
//Stickiness //Stickiness
if ((dx*dx + dy*dy)>1.5 && (gel || !sim->elements[rt].Falldown || (fabs((float)rx)<2 && fabs((float)ry)<2))) if ((dx*dx + dy*dy)>1.5 && (gel || !sim->elements[rt].Falldown || (fabs((float)rx)<2 && fabs((float)ry)<2)))
@ -142,8 +142,8 @@ int Element_GEL::update(UPDATE_FUNC_ARGS)
parts[i].vy += dy; parts[i].vy += dy;
if ((sim->elements[rt].Properties&TYPE_PART) || rt==PT_GOO) if ((sim->elements[rt].Properties&TYPE_PART) || rt==PT_GOO)
{ {
parts[r>>8].vx -= dx; parts[ID(r)].vx -= dx;
parts[r>>8].vy -= dy; parts[ID(r)].vy -= dy;
} }
} }
} }

View File

@ -59,8 +59,8 @@ int Element_GLOW::update(UPDATE_FUNC_ARGS)
if ((r&0xFF)==PT_WATR && !(rand()%400)) if ((r&0xFF)==PT_WATR && !(rand()%400))
{ {
sim->kill_part(i); sim->kill_part(i);
sim->part_change_type(r>>8,x+rx,y+ry,PT_DEUT); sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT);
parts[r>>8].life = 10; parts[ID(r)].life = 10;
return 1; return 1;
} }
} }

View File

@ -62,10 +62,10 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS)
if ((!rx != !ry) && BOUNDS_CHECK) { if ((!rx != !ry) && BOUNDS_CHECK) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if(!r) continue; if(!r) continue;
if((r&0xFF)==PT_BMTL && parts[r>>8].tmp) if((r&0xFF)==PT_BMTL && parts[ID(r)].tmp)
{ {
parts[r>>8].tmp = 0; parts[ID(r)].tmp = 0;
sim->part_change_type(r>>8, x+rx, y+ry, PT_IRON); sim->part_change_type(ID(r), x+rx, y+ry, PT_IRON);
} }
} }
} }
@ -78,7 +78,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK) { if (BOUNDS_CHECK) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if(!r) continue; if(!r) continue;
if((r&0xFF)==PT_SPRK && parts[r>>8].life && parts[r>>8].life<4) if((r&0xFF)==PT_SPRK && parts[ID(r)].life && parts[ID(r)].life<4)
{ {
sim->part_change_type(i, x, y, PT_SPRK); sim->part_change_type(i, x, y, PT_SPRK);
parts[i].life = 4; parts[i].life = 4;

View File

@ -71,10 +71,10 @@ int Element_GPMP::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_GPMP) if ((r&0xFF)==PT_GPMP)
{ {
if (parts[r>>8].life<10&&parts[r>>8].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[r>>8].life==0) else if (parts[ID(r)].life==0)
parts[r>>8].life = 10; parts[ID(r)].life = 10;
} }
} }
} }

View File

@ -58,30 +58,30 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
rt = (r&0xFF); rt = (r&0xFF);
if (sim->pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure if (sim->pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);
sim->part_change_type(i,x,y,PT_OIL); sim->part_change_type(i,x,y,PT_OIL);
return 1; return 1;
} }
if (sim->pv[y/CELL][x/CELL] > 45.0f) if (sim->pv[y/CELL][x/CELL] > 45.0f)
{ {
if (parts[r>>8].temp > 2273.15) if (parts[ID(r)].temp > 2273.15)
continue; continue;
} }
else else
{ {
if (rt==PT_FIRE) if (rt==PT_FIRE)
{ {
if(parts[r>>8].tmp&0x02) if(parts[ID(r)].tmp&0x02)
parts[r>>8].temp=3473.0f; parts[ID(r)].temp=3473.0f;
else else
parts[r>>8].temp=2473.15f; parts[ID(r)].temp=2473.15f;
parts[r>>8].tmp |= 1; parts[ID(r)].tmp |= 1;
sim->create_part(i,x,y,PT_FIRE); sim->create_part(i,x,y,PT_FIRE);
parts[i].temp+=(rand()%100); parts[i].temp+=(rand()%100);
parts[i].tmp |= 1; parts[i].tmp |= 1;
return 1; return 1;
} }
else if ((rt==PT_PLSM && !(parts[r>>8].tmp&4)) || (rt==PT_LAVA && parts[r>>8].ctype != PT_BMTL)) else if ((rt==PT_PLSM && !(parts[ID(r)].tmp&4)) || (rt==PT_LAVA && parts[ID(r)].ctype != PT_BMTL))
{ {
sim->create_part(i,x,y,PT_FIRE); sim->create_part(i,x,y,PT_FIRE);
parts[i].temp+=(rand()%100); parts[i].temp+=(rand()%100);

View File

@ -139,16 +139,16 @@ int Element_HEAC::update(UPDATE_FUNC_ARGS)
if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator)) if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator))
{ {
r = pmap[y+rry][x+rrx]; r = pmap[y+rry][x+rrx];
if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[r>>8].life == 10)) if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10))
{ {
count++; count++;
tempAgg += parts[r>>8].temp; tempAgg += parts[ID(r)].temp;
} }
r = sim->photons[y+rry][x+rrx]; r = sim->photons[y+rry][x+rrx];
if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[r>>8].life == 10)) if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10))
{ {
count++; count++;
tempAgg += parts[r>>8].temp; tempAgg += parts[ID(r)].temp;
} }
} }
} }
@ -167,14 +167,14 @@ int Element_HEAC::update(UPDATE_FUNC_ARGS)
if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator)) if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator))
{ {
r = pmap[y+rry][x+rrx]; r = pmap[y+rry][x+rrx];
if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[r>>8].life == 10)) if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10))
{ {
parts[r>>8].temp = parts[i].temp; parts[ID(r)].temp = parts[i].temp;
} }
r = sim->photons[y+rry][x+rrx]; r = sim->photons[y+rry][x+rrx];
if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[r>>8].life == 10)) if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10))
{ {
parts[r>>8].temp = parts[i].temp; parts[ID(r)].temp = parts[i].temp;
} }
} }
} }

View File

@ -67,14 +67,14 @@ int Element_HSWC::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_HSWC) if ((r&0xFF)==PT_HSWC)
{ {
if (parts[r>>8].life<10&&parts[r>>8].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[r>>8].life==0) else if (parts[ID(r)].life==0)
parts[r>>8].life = 10; parts[ID(r)].life = 10;
} }
if (parts[i].tmp == 1 && ((r&0xFF) == PT_FILT || (r&0xFF) == PT_PHOT || (r&0xFF) == PT_BRAY)) if (parts[i].tmp == 1 && ((r&0xFF) == PT_FILT || (r&0xFF) == PT_PHOT || (r&0xFF) == PT_BRAY))
{ {
parts[i].temp = parts[r>>8].ctype - 0x10000000; parts[i].temp = parts[ID(r)].ctype - 0x10000000;
} }
} }
} }

View File

@ -64,14 +64,14 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS)
if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200)) if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200))
{ {
sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(i,x,y,PT_SLTW);
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
return 0; return 0;
} }
} }
else if (((r&0xFF)==PT_FRZZ) && !(rand()%200)) else if (((r&0xFF)==PT_FRZZ) && !(rand()%200))
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
parts[r>>8].ctype = PT_FRZW; parts[ID(r)].ctype = PT_FRZW;
} }
} }
return 0; return 0;

View File

@ -58,7 +58,7 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = r&0xFF;
if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_SPRK || rt==PT_LIGH || (rt==PT_IGNT && parts[r>>8].life==1)) if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_SPRK || rt==PT_LIGH || (rt==PT_IGNT && parts[ID(r)].life==1))
{ {
parts[i].tmp = 1; parts[i].tmp = 1;
} }

View File

@ -92,9 +92,9 @@ int Element_LCRY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == check) if ((r&0xFF)==PT_LCRY && parts[ID(r)].tmp == check)
{ {
parts[r>>8].tmp = setto; parts[ID(r)].tmp = setto;
} }
} }
return 0; return 0;

View File

@ -87,13 +87,13 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
continue; continue;
rt = r&0xFF; rt = r&0xFF;
if ((surround_space || sim->elements[rt].Explosive) && if ((surround_space || sim->elements[rt].Explosive) &&
(rt!=PT_SPNG || parts[r>>8].life==0) && (rt!=PT_SPNG || parts[ID(r)].life==0) &&
sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000))
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_FIRE); sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE);
parts[r>>8].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP); parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP);
parts[r>>8].life = rand()%80+180; parts[ID(r)].life = rand()%80+180;
parts[r>>8].tmp = parts[r>>8].ctype = 0; parts[ID(r)].tmp = parts[ID(r)].ctype = 0;
if (sim->elements[rt].Explosive) if (sim->elements[rt].Explosive)
sim->pv[y/CELL][x/CELL] += 0.25f * CFDS; sim->pv[y/CELL][x/CELL] += 0.25f * CFDS;
} }
@ -106,48 +106,48 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
case PT_THDR: case PT_THDR:
case PT_DMND: case PT_DMND:
case PT_FIRE: case PT_FIRE:
parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful/10, MIN_TEMP, MAX_TEMP);
continue; continue;
case PT_DEUT: case PT_DEUT:
case PT_PLUT: case PT_PLUT:
parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful, MIN_TEMP, MAX_TEMP); parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful, MIN_TEMP, MAX_TEMP);
sim->pv[y/CELL][x/CELL] +=powderful/35; sim->pv[y/CELL][x/CELL] +=powderful/35;
if (!(rand()%3)) if (!(rand()%3))
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_NEUT); sim->part_change_type(ID(r),x+rx,y+ry,PT_NEUT);
parts[r>>8].life = rand()%480+480; parts[ID(r)].life = rand()%480+480;
parts[r>>8].vx=rand()%10-5; parts[ID(r)].vx=rand()%10-5;
parts[r>>8].vy=rand()%10-5; parts[ID(r)].vy=rand()%10-5;
} }
break; break;
case PT_COAL: case PT_COAL:
case PT_BCOL: case PT_BCOL:
if (parts[r>>8].life>100) if (parts[ID(r)].life>100)
parts[r>>8].life = 99; parts[ID(r)].life = 99;
break; break;
case PT_STKM: case PT_STKM:
if (sim->player.elem!=PT_LIGH) if (sim->player.elem!=PT_LIGH)
parts[r>>8].life-=powderful/100; parts[ID(r)].life-=powderful/100;
break; break;
case PT_STKM2: case PT_STKM2:
if (sim->player2.elem!=PT_LIGH) if (sim->player2.elem!=PT_LIGH)
parts[r>>8].life-=powderful/100; parts[ID(r)].life-=powderful/100;
break; break;
case PT_HEAC: case PT_HEAC:
parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful/10, MIN_TEMP, MAX_TEMP);
if (parts[r>>8].temp > sim->elements[PT_HEAC].HighTemperature) if (parts[ID(r)].temp > sim->elements[PT_HEAC].HighTemperature)
{ {
sim->part_change_type(r>>8, x+rx, y+ry, PT_LAVA); sim->part_change_type(ID(r), x+rx, y+ry, PT_LAVA);
parts[r>>8].ctype = PT_HEAC; parts[ID(r)].ctype = PT_HEAC;
} }
break; break;
default: default:
break; break;
} }
if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0) if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0)
sim->create_part(r>>8,x+rx,y+ry,PT_SPRK); sim->create_part(ID(r),x+rx,y+ry,PT_SPRK);
sim->pv[y/CELL][x/CELL] += powderful/400; sim->pv[y/CELL][x/CELL] += powderful/400;
if (sim->elements[r&0xFF].HeatConduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.3, MIN_TEMP, MAX_TEMP); if (sim->elements[r&0xFF].HeatConduct) parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful/1.3, MIN_TEMP, MAX_TEMP);
} }
if (parts[i].tmp2==3) if (parts[i].tmp2==3)
{ {
@ -260,7 +260,7 @@ int Element_LIGH::contact_part(Simulation * sim, int i, int tp)
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==tp) if ((r&0xFF)==tp)
return r>>8; return ID(r);
} }
return -1; return -1;
} }
@ -287,7 +287,7 @@ bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp,
else if (x >= 0 && x < XRES && y >= 0 && y < YRES) else if (x >= 0 && x < XRES && y >= 0 && y < YRES)
{ {
int r = sim->pmap[y][x]; int r = sim->pmap[y][x];
if ((((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && sim->parts[r>>8].life >= 10)) && (!sim->parts[r>>8].ctype || (sim->parts[r>>8].ctype==c)!=(sim->parts[r>>8].tmp&1))) || (r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) // VOID, PVOD, VACU, and BHOL eat LIGH here if ((((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && sim->parts[ID(r)].life >= 10)) && (!sim->parts[ID(r)].ctype || (sim->parts[ID(r)].ctype==c)!=(sim->parts[ID(r)].tmp&1))) || (r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) // VOID, PVOD, VACU, and BHOL eat LIGH here
return true; return true;
} }
else return true; else return true;

View File

@ -60,13 +60,13 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = r&0xFF;
if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL) if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
{ {
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0) if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
{ {
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = rt; parts[ID(r)].ctype = rt;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
} }
} }
} }
@ -80,7 +80,7 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if(!r) if(!r)
continue; continue;
if (parts[r>>8].life > parts[i].temp-273.15) if (parts[ID(r)].life > parts[i].temp-273.15)
parts[i].life = 1; parts[i].life = 1;
} }
return 0; return 0;

View File

@ -73,10 +73,10 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_MERC&& !(rand()%3)) if ((r&0xFF)==PT_MERC&& !(rand()%3))
{ {
if ((parts[i].tmp + parts[r>>8].tmp + 1) <= maxtmp) if ((parts[i].tmp + parts[ID(r)].tmp + 1) <= maxtmp)
{ {
parts[i].tmp += parts[r>>8].tmp + 1; parts[i].tmp += parts[ID(r)].tmp + 1;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
} }
@ -108,17 +108,17 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_MERC&&(parts[i].tmp>parts[r>>8].tmp)&&parts[i].tmp>0)//diffusion if ((r&0xFF)==PT_MERC&&(parts[i].tmp>parts[ID(r)].tmp)&&parts[i].tmp>0)//diffusion
{ {
int temp = parts[i].tmp - parts[r>>8].tmp; int temp = parts[i].tmp - parts[ID(r)].tmp;
if (temp ==1) if (temp ==1)
{ {
parts[r>>8].tmp ++; parts[ID(r)].tmp ++;
parts[i].tmp --; parts[i].tmp --;
} }
else if (temp>0) else if (temp>0)
{ {
parts[r>>8].tmp += temp/2; parts[ID(r)].tmp += temp/2;
parts[i].tmp -= temp/2; parts[i].tmp -= temp/2;
} }
} }

View File

@ -59,7 +59,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
{ {
case PT_WATR: case PT_WATR:
if (3>(rand()%20)) if (3>(rand()%20))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DSTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_DSTW);
case PT_ICEI: case PT_ICEI:
case PT_SNOW: case PT_SNOW:
parts[i].vx *= 0.995; parts[i].vx *= 0.995;
@ -70,18 +70,18 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
{ {
if (!(rand()%3)) if (!(rand()%3))
{ {
sim->create_part(r>>8, x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN); sim->create_part(ID(r), x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN);
parts[r>>8].temp = MAX_TEMP; parts[ID(r)].temp = MAX_TEMP;
if (parts[r>>8].type==PT_LAVA) { if (parts[ID(r)].type==PT_LAVA) {
parts[r>>8].tmp = 100; parts[ID(r)].tmp = 100;
parts[r>>8].ctype = PT_PLUT; parts[ID(r)].ctype = PT_PLUT;
} }
} }
else else
{ {
sim->create_part(r>>8, x+rx, y+ry, PT_NEUT); sim->create_part(ID(r), x+rx, y+ry, PT_NEUT);
parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx;
parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy;
} }
sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
@ -89,21 +89,21 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
break; break;
#ifdef SDEUT #ifdef SDEUT
case PT_DEUT: case PT_DEUT:
if ((pressureFactor+1+(parts[r>>8].life/100))>(rand()%1000)) if ((pressureFactor+1+(parts[ID(r)].life/100))>(rand()%1000))
{ {
DeutExplosion(sim, parts[r>>8].life, x+rx, y+ry, restrict_flt(parts[r>>8].temp + parts[r>>8].life*500.0f, MIN_TEMP, MAX_TEMP), PT_NEUT); DeutExplosion(sim, parts[ID(r)].life, x+rx, y+ry, restrict_flt(parts[ID(r)].temp + parts[ID(r)].life*500.0f, MIN_TEMP, MAX_TEMP), PT_NEUT);
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
break; break;
#else #else
case PT_DEUT: case PT_DEUT:
if ((pressureFactor+1)>(rand()%1000)) if ((pressureFactor+1)>(rand()%1000))
{ {
create_part(r>>8, x+rx, y+ry, PT_NEUT); create_part(ID(r), x+rx, y+ry, PT_NEUT);
parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx;
parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy;
parts[r>>8].life --; parts[ID(r)].life --;
parts[r>>8].temp = restrict_flt(parts[r>>8].temp + parts[r>>8].life*17.0f, MIN_TEMP, MAX_TEMP); parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp + parts[ID(r)].life*17.0f, MIN_TEMP, MAX_TEMP);
pv[y/CELL][x/CELL] += 6.0f * CFDS; pv[y/CELL][x/CELL] += 6.0f * CFDS;
} }
@ -111,51 +111,51 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
#endif #endif
case PT_GUNP: case PT_GUNP:
if (3>(rand()%200)) if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DUST); sim->part_change_type(ID(r),x+rx,y+ry,PT_DUST);
break; break;
case PT_DYST: case PT_DYST:
if (3>(rand()%200)) if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_YEST); sim->part_change_type(ID(r),x+rx,y+ry,PT_YEST);
break; break;
case PT_YEST: case PT_YEST:
sim->part_change_type(r>>8,x+rx,y+ry,PT_DYST); sim->part_change_type(ID(r),x+rx,y+ry,PT_DYST);
break; break;
case PT_PLEX: case PT_PLEX:
if (3>(rand()%200)) if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_GOO); sim->part_change_type(ID(r),x+rx,y+ry,PT_GOO);
break; break;
case PT_NITR: case PT_NITR:
if (3>(rand()%200)) if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DESL); sim->part_change_type(ID(r),x+rx,y+ry,PT_DESL);
break; break;
case PT_PLNT: case PT_PLNT:
if (!(rand()%20)) if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_WOOD); sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
break; break;
case PT_DESL: case PT_DESL:
case PT_OIL: case PT_OIL:
if (3>(rand()%200)) if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_GAS); sim->part_change_type(ID(r),x+rx,y+ry,PT_GAS);
break; break;
case PT_COAL: case PT_COAL:
if (!(rand()%20)) if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_WOOD); sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
break; break;
case PT_BCOL: case PT_BCOL:
if (!(rand()%20)) if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_SAWD); sim->create_part(ID(r), x+rx, y+ry, PT_SAWD);
break; break;
case PT_DUST: case PT_DUST:
if (!(rand()%20)) if (!(rand()%20))
sim->part_change_type(r>>8, x+rx, y+ry, PT_FWRK); sim->part_change_type(ID(r), x+rx, y+ry, PT_FWRK);
break; break;
case PT_FWRK: case PT_FWRK:
if (!(rand()%20)) if (!(rand()%20))
parts[r>>8].ctype = PT_DUST; parts[ID(r)].ctype = PT_DUST;
break; break;
case PT_ACID: case PT_ACID:
if (!(rand()%20)) if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_ISOZ); sim->create_part(ID(r), x+rx, y+ry, PT_ISOZ);
break; break;
case PT_TTAN: case PT_TTAN:
if (!(rand()%20)) if (!(rand()%20))
@ -166,13 +166,13 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
break; break;
case PT_EXOT: case PT_EXOT:
if (!(rand()%20)) if (!(rand()%20))
parts[r>>8].life = 1500; parts[ID(r)].life = 1500;
break; break;
case PT_RFRG: case PT_RFRG:
if (rand()%2) if (rand()%2)
sim->create_part(r>>8, x+rx, y+ry, PT_GAS); sim->create_part(ID(r), x+rx, y+ry, PT_GAS);
else else
sim->create_part(r>>8, x+rx, y+ry, PT_CAUS); sim->create_part(ID(r), x+rx, y+ry, PT_CAUS);
break; break;
default: default:
break; break;

View File

@ -58,16 +58,16 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
if ((r&0xFF)==PT_FIRE) if ((r&0xFF)==PT_FIRE)
{ {
parts[r>>8].temp+=(rand()%100); parts[ID(r)].temp+=(rand()%100);
if(parts[r>>8].tmp&0x01) if(parts[ID(r)].tmp&0x01)
parts[r>>8].temp=3473; parts[ID(r)].temp=3473;
parts[r>>8].tmp |= 2; parts[ID(r)].tmp |= 2;
sim->create_part(i,x,y,PT_FIRE); sim->create_part(i,x,y,PT_FIRE);
parts[i].temp+=(rand()%100); parts[i].temp+=(rand()%100);
parts[i].tmp |= 2; parts[i].tmp |= 2;
} }
else if ((r&0xFF)==PT_PLSM && !(parts[r>>8].tmp&4)) else if ((r&0xFF)==PT_PLSM && !(parts[ID(r)].tmp&4))
{ {
sim->create_part(i,x,y,PT_FIRE); sim->create_part(i,x,y,PT_FIRE);
parts[i].temp+=(rand()%100); parts[i].temp+=(rand()%100);

View File

@ -82,7 +82,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
{ {
parts[i].ctype = rt; parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA) if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype; parts[i].tmp = parts[ID(r)].ctype;
} }
} }
if (parts[i].life!=10) if (parts[i].life!=10)
@ -101,10 +101,10 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_PBCN) if ((r&0xFF)==PT_PBCN)
{ {
if (parts[r>>8].life<10&&parts[r>>8].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[r>>8].life==0) else if (parts[ID(r)].life==0)
parts[r>>8].life = 10; parts[ID(r)].life = 10;
} }
} }
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled) if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled)

View File

@ -60,19 +60,19 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_SPRK) if ((r&0xFF)==PT_SPRK)
{ {
if (parts[r>>8].life>0 && parts[r>>8].life<4) if (parts[ID(r)].life>0 && parts[ID(r)].life<4)
{ {
if (parts[r>>8].ctype==PT_PSCN) if (parts[ID(r)].ctype==PT_PSCN)
parts[i].life = 10; parts[i].life = 10;
else if (parts[r>>8].ctype==PT_NSCN) else if (parts[ID(r)].ctype==PT_NSCN)
parts[i].life = 9; parts[i].life = 9;
} }
} }
else if ((r&0xFF)==PT_PCLN) else if ((r&0xFF)==PT_PCLN)
{ {
if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) if (parts[i].life==10&&parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[i].life==0&&parts[r>>8].life==10) else if (parts[i].life==0&&parts[ID(r)].life==10)
parts[i].life = 10; parts[i].life = 10;
} }
} }
@ -95,7 +95,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
{ {
parts[i].ctype = rt; parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA) if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype; parts[i].tmp = parts[ID(r)].ctype;
} }
} }
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10) if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10)

View File

@ -68,14 +68,14 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
{ {
parts[i].vx *= 0.90; parts[i].vx *= 0.90;
parts[i].vy *= 0.90; parts[i].vy *= 0.90;
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT); sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
rrr = (rand()%360)*3.14159f/180.0f; rrr = (rand()%360)*3.14159f/180.0f;
if ((r&0xFF) == PT_ISOZ) if ((r&0xFF) == PT_ISOZ)
rr = (rand()%128+128)/127.0f; rr = (rand()%128+128)/127.0f;
else else
rr = (rand()%228+128)/127.0f; rr = (rand()%228+128)/127.0f;
parts[r>>8].vx = rr*cosf(rrr); parts[ID(r)].vx = rr*cosf(rrr);
parts[r>>8].vy = rr*sinf(rrr); parts[ID(r)].vy = rr*sinf(rrr);
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS; sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
} }
} }
@ -98,7 +98,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
parts[i].vx = vx; parts[i].vx = vx;
parts[i].vy = vy; parts[i].vy = vy;
} }
else if ((r&0xFF) == PT_FILT && parts[r>>8].tmp==9) else if ((r&0xFF) == PT_FILT && parts[ID(r)].tmp==9)
{ {
parts[i].vx += ((float)(rand()%1000-500))/1000.0f; parts[i].vx += ((float)(rand()%1000-500))/1000.0f;
parts[i].vy += ((float)(rand()%1000-500))/1000.0f; parts[i].vy += ((float)(rand()%1000-500))/1000.0f;

View File

@ -104,9 +104,9 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
if ((r&0xFF) == PT_BRCK) if ((r&0xFF) == PT_BRCK)
{ {
if (parts[i].tmp & PPIP_TMPFLAG_PAUSED) if (parts[i].tmp & PPIP_TMPFLAG_PAUSED)
parts[r>>8].tmp = 0; parts[ID(r)].tmp = 0;
else else
parts[r>>8].tmp = 1; //make surrounding BRCK glow parts[ID(r)].tmp = 1; //make surrounding BRCK glow
} }
} }
} }
@ -146,24 +146,24 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[r>>8].ctype==1) if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[ID(r)].ctype==1)
{ {
parts[r>>8].ctype = (((parts[i].ctype)%3)+2);//reverse parts[ID(r)].ctype = (((parts[i].ctype)%3)+2);//reverse
parts[r>>8].life = 6; parts[ID(r)].life = 6;
if ( parts[i].tmp&0x100)//is a single pixel pipe if ( parts[i].tmp&0x100)//is a single pixel pipe
{ {
parts[r>>8].tmp |= 0x200;//will transfer to a single pixel pipe parts[ID(r)].tmp |= 0x200;//will transfer to a single pixel pipe
parts[r>>8].tmp |= count<<10;//coords of where it came from parts[ID(r)].tmp |= count<<10;//coords of where it came from
parts[i].tmp |= ((7-count)<<14); parts[i].tmp |= ((7-count)<<14);
parts[i].tmp |= 0x2000; parts[i].tmp |= 0x2000;
} }
neighborcount ++; neighborcount ++;
lastneighbor = r>>8; lastneighbor = ID(r);
} }
else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[r>>8].ctype!=(((parts[i].ctype-1)%3)+2)) else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[ID(r)].ctype!=(((parts[i].ctype-1)%3)+2))
{ {
neighborcount ++; neighborcount ++;
lastneighbor = r>>8; lastneighbor = ID(r);
} }
count++; count++;
} }
@ -205,14 +205,14 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
else if ((parts[i].tmp&0xFF) == 0 && (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) else if ((parts[i].tmp&0xFF) == 0 && (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
{ {
if ((r&0xFF)==PT_SOAP) if ((r&0xFF)==PT_SOAP)
Element_SOAP::detach(sim, r>>8); Element_SOAP::detach(sim, ID(r));
transfer_part_to_pipe(parts+(r>>8), parts+i); transfer_part_to_pipe(parts+(ID(r)), parts+i);
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[r>>8].tmp>0 && sim->IsValidElement(parts[r>>8].tmp) && (sim->elements[parts[r>>8].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[ID(r)].tmp>0 && sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
{ {
// STOR stores properties in the same places as PIPE does // STOR stores properties in the same places as PIPE does
transfer_pipe_to_pipe(parts+(r>>8), parts+i); transfer_pipe_to_pipe(parts+(ID(r)), parts+i);
} }
} }
} }
@ -415,17 +415,17 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
r = sim->pmap[y+ry][x+rx]; r = sim->pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && sim->parts[r>>8].ctype!=notctype && (sim->parts[r>>8].tmp&0xFF)==0) else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0)
{ {
transfer_pipe_to_pipe(sim->parts+i, sim->parts+(r>>8)); transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)));
if (r>>8 > original) if (ID(r) > original)
sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed
count++; count++;
pushParticle(sim, r>>8,count,original); pushParticle(sim, ID(r),count,original);
} }
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
{ {
int portaltmp = sim->parts[r>>8].tmp; int portaltmp = sim->parts[ID(r)].tmp;
if (portaltmp >= CHANNELS) if (portaltmp >= CHANNELS)
portaltmp = CHANNELS-1; portaltmp = CHANNELS-1;
else if (portaltmp < 0) else if (portaltmp < 0)
@ -445,17 +445,17 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
{ {
int coords = 7 - ((sim->parts[i].tmp>>10)&7); int coords = 7 - ((sim->parts[i].tmp>>10)&7);
r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]];
if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && sim->parts[r>>8].ctype!=notctype && (sim->parts[r>>8].tmp&0xFF)==0) if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0)
{ {
transfer_pipe_to_pipe(sim->parts+i, sim->parts+(r>>8)); transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)));
if (r>>8 > original) if (ID(r) > original)
sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed
count++; count++;
pushParticle(sim, r>>8,count,original); pushParticle(sim, ID(r),count,original);
} }
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
{ {
int portaltmp = sim->parts[r>>8].tmp; int portaltmp = sim->parts[ID(r)].tmp;
if (portaltmp >= CHANNELS) if (portaltmp >= CHANNELS)
portaltmp = CHANNELS-1; portaltmp = CHANNELS-1;
else if (portaltmp < 0) else if (portaltmp < 0)

View File

@ -62,7 +62,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
case PT_WATR: case PT_WATR:
if (!(rand()%50)) if (!(rand()%50))
{ {
np = sim->create_part(r>>8,x+rx,y+ry,PT_PLNT); np = sim->create_part(ID(r),x+rx,y+ry,PT_PLNT);
if (np<0) continue; if (np<0) continue;
parts[np].life = 0; parts[np].life = 0;
} }
@ -78,7 +78,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
case PT_CO2: case PT_CO2:
if (!(rand()%50)) if (!(rand()%50))
{ {
sim->kill_part(r>>8); sim->kill_part(ID(r));
parts[i].life = rand()%60 + 60; parts[i].life = rand()%60 + 60;
} }
break; break;

View File

@ -73,15 +73,15 @@ int Element_POLO::update(UPDATE_FUNC_ARGS)
int s = sim->create_part(-3, x, y, PT_NEUT); int s = sim->create_part(-3, x, y, PT_NEUT);
if (s >= 0) if (s >= 0)
{ {
parts[i].temp = ((parts[i].temp + parts[r>>8].temp + parts[r>>8].temp) + 600.0f) / 3.0f; parts[i].temp = ((parts[i].temp + parts[ID(r)].temp + parts[ID(r)].temp) + 600.0f) / 3.0f;
parts[i].life = COOLDOWN; parts[i].life = COOLDOWN;
parts[i].tmp++; parts[i].tmp++;
parts[r>>8].temp = parts[i].temp; parts[ID(r)].temp = parts[i].temp;
parts[s].temp = parts[i].temp; parts[s].temp = parts[i].temp;
parts[s].vx = parts[r>>8].vx; parts[s].vx = parts[ID(r)].vx;
parts[s].vy = parts[r>>8].vy; parts[s].vy = parts[ID(r)].vy;
} }
} }
} }
@ -91,10 +91,10 @@ int Element_POLO::update(UPDATE_FUNC_ARGS)
parts[i].temp = (parts[i].temp+600.0f)/2.0f; parts[i].temp = (parts[i].temp+600.0f)/2.0f;
return 1; return 1;
} }
if (parts[r>>8].type == PT_PROT) if (parts[ID(r)].type == PT_PROT)
{ {
parts[i].tmp2++; parts[i].tmp2++;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
if (parts[i].temp < 388.15f) if (parts[i].temp < 388.15f)
{ {

View File

@ -84,27 +84,27 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS)
continue;// Handling these is a bit more complicated, and is done in STKM_interact() continue;// Handling these is a bit more complicated, and is done in STKM_interact()
if ((r&0xFF) == PT_SOAP) if ((r&0xFF) == PT_SOAP)
Element_SOAP::detach(sim, r>>8); Element_SOAP::detach(sim, ID(r));
for (int nnx=0; nnx<80; nnx++) for (int nnx=0; nnx<80; nnx++)
if (!sim->portalp[parts[i].tmp][count][nnx].type) if (!sim->portalp[parts[i].tmp][count][nnx].type)
{ {
if ((r&0xFF) == PT_STOR) if ((r&0xFF) == PT_STOR)
{ {
if (sim->IsValidElement(parts[r>>8].tmp) && (sim->elements[parts[r>>8].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) if (sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
{ {
// STOR uses same format as PIPE, so we can use this function to do the transfer // STOR uses same format as PIPE, so we can use this function to do the transfer
Element_PIPE::transfer_pipe_to_part(sim, parts+(r>>8), &sim->portalp[parts[i].tmp][count][nnx]); Element_PIPE::transfer_pipe_to_part(sim, parts+(ID(r)), &sim->portalp[parts[i].tmp][count][nnx]);
break; break;
} }
} }
else else
{ {
sim->portalp[parts[i].tmp][count][nnx] = parts[r>>8]; sim->portalp[parts[i].tmp][count][nnx] = parts[ID(r)];
if ((r&0xFF) == PT_SPRK) if ((r&0xFF) == PT_SPRK)
sim->part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype); sim->part_change_type(ID(r),x+rx,y+ry,parts[ID(r)].ctype);
else else
sim->kill_part(r>>8); sim->kill_part(ID(r));
fe = 1; fe = 1;
break; break;
} }

View File

@ -59,13 +59,13 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = r&0xFF;
if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL) if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
{ {
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0) if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
{ {
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = rt; parts[ID(r)].ctype = rt;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
} }
} }
} }

View File

@ -88,8 +88,8 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) { if ((r&0xFF)==PT_SPRK && parts[ID(r)].life==3) {
if(parts[r>>8].ctype == PT_PSCN) if(parts[ID(r)].ctype == PT_PSCN)
state = PISTON_EXTEND; state = PISTON_EXTEND;
else else
state = PISTON_RETRACT; state = PISTON_RETRACT;
@ -121,7 +121,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
r = pmap[y+nyy][x+nxx]; r = pmap[y+nyy][x+nxx];
if((r&0xFF)==PT_PSTN) if((r&0xFF)==PT_PSTN)
{ {
if(parts[r>>8].life) if(parts[ID(r)].life)
armCount++; armCount++;
else if (armCount) else if (armCount)
{ {
@ -132,7 +132,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
} }
else else
{ {
pistonCount += floor((parts[r>>8].temp-268.15)/10);// How many tens of degrees above 0 C, rounded to nearest ten degrees. Can be negative. 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.
} }
} }
else if (nxx==0 && nyy==0) else if (nxx==0 && nyy==0)
@ -214,7 +214,7 @@ Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX,
else else
{ {
if (currentPos - spaces < maxSize && (!retract || ((r&0xFF) == PT_FRME && posX == stackX && posY == stackY))) if (currentPos - spaces < maxSize && (!retract || ((r&0xFF) == PT_FRME && posX == stackX && posY == stackY)))
tempParts[currentPos++] = r>>8; tempParts[currentPos++] = ID(r);
else else
return StackData(currentPos - spaces, spaces); return StackData(currentPos - spaces, spaces);
} }
@ -293,7 +293,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
break; break;
} else { } else {
foundParts = true; foundParts = true;
tempParts[currentPos++] = r>>8; tempParts[currentPos++] = ID(r);
} }
} }
if(foundParts) { if(foundParts) {

View File

@ -76,10 +76,10 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_PUMP) if ((r&0xFF)==PT_PUMP)
{ {
if (parts[r>>8].life<10&&parts[r>>8].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[r>>8].life==0) else if (parts[ID(r)].life==0)
parts[r>>8].life = 10; parts[ID(r)].life = 10;
} }
} }
} }

View File

@ -60,19 +60,19 @@ int Element_PVOD::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)==PT_SPRK) if ((r&0xFF)==PT_SPRK)
{ {
if (parts[r>>8].life>0 && parts[r>>8].life<4) if (parts[ID(r)].life>0 && parts[ID(r)].life<4)
{ {
if (parts[r>>8].ctype==PT_PSCN) if (parts[ID(r)].ctype==PT_PSCN)
parts[i].life = 10; parts[i].life = 10;
else if (parts[r>>8].ctype==PT_NSCN) else if (parts[ID(r)].ctype==PT_NSCN)
parts[i].life = 9; parts[i].life = 9;
} }
} }
else if ((r&0xFF)==PT_PVOD) else if ((r&0xFF)==PT_PVOD)
{ {
if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) if (parts[i].life==10&&parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[i].life==0&&parts[r>>8].life==10) else if (parts[i].life==0&&parts[ID(r)].life==10)
parts[i].life = 10; parts[i].life = 10;
} }
} }

View File

@ -72,7 +72,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
continue; continue;
else if ((r&0xFF)==PT_SLTW && !(rand()%500)) else if ((r&0xFF)==PT_SLTW && !(rand()%500))
{ {
sim->kill_part(r>>8); sim->kill_part(ID(r));
parts[i].tmp++; parts[i].tmp++;
} }
} }
@ -122,18 +122,18 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
else if ((r&0xFF)==PT_QRTZ && (parts[i].tmp>parts[r>>8].tmp) && parts[r>>8].tmp>=0) else if ((r&0xFF)==PT_QRTZ && (parts[i].tmp>parts[ID(r)].tmp) && parts[ID(r)].tmp>=0)
{ {
tmp = parts[i].tmp - parts[r>>8].tmp; tmp = parts[i].tmp - parts[ID(r)].tmp;
if (tmp ==1) if (tmp ==1)
{ {
parts[r>>8].tmp++; parts[ID(r)].tmp++;
parts[i].tmp--; parts[i].tmp--;
break; break;
} }
if (tmp>0) if (tmp>0)
{ {
parts[r>>8].tmp += tmp/2; parts[ID(r)].tmp += tmp/2;
parts[i].tmp -= tmp/2; parts[i].tmp -= tmp/2;
break; break;
} }

View File

@ -60,10 +60,10 @@ int Element_RIME::update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_FOG); sim->part_change_type(i,x,y,PT_FOG);
parts[i].life = rand()%50 + 60; parts[i].life = rand()%50 + 60;
} }
else if ((r&0xFF)==PT_FOG&&parts[r>>8].life>0) else if ((r&0xFF)==PT_FOG&&parts[ID(r)].life>0)
{ {
sim->part_change_type(i,x,y,PT_FOG); sim->part_change_type(i,x,y,PT_FOG);
parts[i].life = parts[r>>8].life; parts[i].life = parts[ID(r)].life;
} }
} }
return 0; return 0;

View File

@ -59,9 +59,9 @@ int Element_RPEL::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)) { if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)) {
if (!parts[i].ctype || parts[i].ctype == parts[r>>8].type) { if (!parts[i].ctype || parts[i].ctype == parts[ID(r)].type) {
parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vx += isign(rx)*((parts[i].temp-273.15)/10.0f);
parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vy += isign(ry)*((parts[i].temp-273.15)/10.0f);
} }
} }
} }

View File

@ -66,8 +66,8 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS)
} }
if ((r&0xFF)==PT_SHLD1 && parts[i].life>3) if ((r&0xFF)==PT_SHLD1 && parts[i].life>3)
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD2); sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD2);
parts[r>>8].life=7; parts[ID(r)].life=7;
} }
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{ {

View File

@ -67,8 +67,8 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS)
} }
if ((r&0xFF)==PT_SHLD2 && parts[i].life>3) if ((r&0xFF)==PT_SHLD2 && parts[i].life>3)
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD3); sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD3);
parts[r>>8].life = 7; parts[ID(r)].life = 7;
} }
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
for ( nnx=-1; nnx<2; nnx++) for ( nnx=-1; nnx<2; nnx++)

View File

@ -113,20 +113,20 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)!=PT_DMND&& !(rand()%3)) if ((r&0xFF)!=PT_DMND&& !(rand()%3))
{ {
if ((r&0xFF)==PT_SING && parts[r>>8].life >10) if ((r&0xFF)==PT_SING && parts[ID(r)].life >10)
{ {
if (parts[i].life+parts[r>>8].life > 255) if (parts[i].life+parts[ID(r)].life > 255)
continue; continue;
parts[i].life += parts[r>>8].life; parts[i].life += parts[ID(r)].life;
} }
else else
{ {
if (parts[i].life+3 > 255) if (parts[i].life+3 > 255)
{ {
if (parts[r>>8].type!=PT_SING && !(rand()%100)) if (parts[ID(r)].type!=PT_SING && !(rand()%100))
{ {
int np; int np;
np = sim->create_part(r>>8,x+rx,y+ry,PT_SING); np = sim->create_part(ID(r),x+rx,y+ry,PT_SING);
parts[np].life = rand()%50+60; parts[np].life = rand()%50+60;
} }
continue; continue;
@ -134,8 +134,8 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
parts[i].life += 3; parts[i].life += 3;
parts[i].tmp++; parts[i].tmp++;
} }
parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); parts[i].temp = restrict_flt(parts[ID(r)].temp+parts[i].temp, MIN_TEMP, MAX_TEMP);
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
} }
return 0; return 0;

View File

@ -57,11 +57,11 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
{ {
case PT_SALT: case PT_SALT:
if (!(rand()%2000)) if (!(rand()%2000))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
break; break;
case PT_PLNT: case PT_PLNT:
if (!(rand()%40)) if (!(rand()%40))
sim->kill_part(r>>8); sim->kill_part(ID(r));
break; break;
case PT_RBDM: case PT_RBDM:
case PT_LRBD: case PT_LRBD:
@ -73,9 +73,9 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
} }
break; break;
case PT_FIRE: case PT_FIRE:
if (parts[r>>8].ctype!=PT_WATR) if (parts[ID(r)].ctype!=PT_WATR)
{ {
sim->kill_part(r>>8); sim->kill_part(ID(r));
if(!(rand()%30)){ if(!(rand()%30)){
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;

View File

@ -63,7 +63,7 @@ int Element_SNOW::update(UPDATE_FUNC_ARGS)
if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && !(rand()%333)) if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && !(rand()%333))
{ {
sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(i,x,y,PT_SLTW);
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
} }
} }
return 0; return 0;

View File

@ -146,8 +146,8 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((parts[r>>8].type == PT_SOAP) && (parts[r>>8].ctype&1) && !(parts[r>>8].ctype&4)) if ((parts[ID(r)].type == PT_SOAP) && (parts[ID(r)].ctype&1) && !(parts[ID(r)].ctype&4))
Element_SOAP::attach(parts, i, r>>8); Element_SOAP::attach(parts, i, ID(r));
} }
} }
else else
@ -172,25 +172,25 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
} }
if ((r&0xFF) == PT_SOAP) if ((r&0xFF) == PT_SOAP)
{ {
if (parts[r>>8].ctype == 1) if (parts[ID(r)].ctype == 1)
{ {
int buf = parts[i].tmp; int buf = parts[i].tmp;
parts[i].tmp = r>>8; parts[i].tmp = ID(r);
if (parts[buf].type == PT_SOAP) if (parts[buf].type == PT_SOAP)
parts[buf].tmp2 = r>>8; parts[buf].tmp2 = ID(r);
parts[r>>8].tmp2 = i; parts[ID(r)].tmp2 = i;
parts[r>>8].tmp = buf; parts[ID(r)].tmp = buf;
parts[r>>8].ctype = 7; parts[ID(r)].ctype = 7;
} }
else if (parts[r>>8].ctype == 7 && parts[i].tmp != r>>8 && parts[i].tmp2 != r>>8) else if (parts[ID(r)].ctype == 7 && parts[i].tmp != ID(r) && parts[i].tmp2 != ID(r))
{ {
if (parts[parts[i].tmp].type == PT_SOAP) if (parts[parts[i].tmp].type == PT_SOAP)
parts[parts[i].tmp].tmp2 = parts[r>>8].tmp2; parts[parts[i].tmp].tmp2 = parts[ID(r)].tmp2;
if (parts[parts[r>>8].tmp2].type == PT_SOAP) if (parts[parts[ID(r)].tmp2].type == PT_SOAP)
parts[parts[r>>8].tmp2].tmp = parts[i].tmp; parts[parts[ID(r)].tmp2].tmp = parts[i].tmp;
parts[r>>8].tmp2 = i; parts[ID(r)].tmp2 = i;
parts[i].tmp = r>>8; parts[i].tmp = ID(r);
} }
} }
} }
@ -240,10 +240,10 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
if ((r&0xFF) == PT_OIL) if ((r&0xFF) == PT_OIL)
{ {
float ax, ay; float ax, ay;
ax = (parts[i].vx*0.5f + parts[r>>8].vx)/2; ax = (parts[i].vx*0.5f + parts[ID(r)].vx)/2;
ay = ((parts[i].vy-0.1f)*0.5f + parts[r>>8].vy)/2; ay = ((parts[i].vy-0.1f)*0.5f + parts[ID(r)].vy)/2;
parts[i].vx = parts[r>>8].vx = ax; parts[i].vx = parts[ID(r)].vx = ax;
parts[i].vy = parts[r>>8].vy = ay; parts[i].vy = parts[ID(r)].vy = ay;
} }
} }
} }
@ -256,15 +256,15 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)!=PT_SOAP) if ((r&0xFF)!=PT_SOAP)
{ {
tr = (parts[r>>8].dcolour>>16)&0xFF; tr = (parts[ID(r)].dcolour>>16)&0xFF;
tg = (parts[r>>8].dcolour>>8)&0xFF; tg = (parts[ID(r)].dcolour>>8)&0xFF;
tb = (parts[r>>8].dcolour)&0xFF; tb = (parts[ID(r)].dcolour)&0xFF;
ta = (parts[r>>8].dcolour>>24)&0xFF; ta = (parts[ID(r)].dcolour>>24)&0xFF;
nr = (tr*BLEND); nr = (tr*BLEND);
ng = (tg*BLEND); ng = (tg*BLEND);
nb = (tb*BLEND); nb = (tb*BLEND);
na = (ta*BLEND); na = (ta*BLEND);
parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; parts[ID(r)].dcolour = nr<<16 | ng<<8 | nb | na<<24;
} }
} }

View File

@ -66,7 +66,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
if (parts[i].life<limit && 500>rand()%absorbChanceDenom) if (parts[i].life<limit && 500>rand()%absorbChanceDenom)
{ {
parts[i].life++; parts[i].life++;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
break; break;
case PT_SLTW: case PT_SLTW:
@ -74,23 +74,23 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
{ {
parts[i].life++; parts[i].life++;
if (rand()%4) if (rand()%4)
sim->kill_part(r>>8); sim->kill_part(ID(r));
else else
sim->part_change_type(r>>8, x+rx, y+ry, PT_SALT); sim->part_change_type(ID(r), x+rx, y+ry, PT_SALT);
} }
break; break;
case PT_CBNW: case PT_CBNW:
if (parts[i].life<limit && 100>rand()%absorbChanceDenom) if (parts[i].life<limit && 100>rand()%absorbChanceDenom)
{ {
parts[i].life++; parts[i].life++;
sim->part_change_type(r>>8, x+rx, y+ry, PT_CO2); sim->part_change_type(ID(r), x+rx, y+ry, PT_CO2);
} }
break; break;
case PT_PSTE: case PT_PSTE:
if (parts[i].life<limit && 20>rand()%absorbChanceDenom) if (parts[i].life<limit && 20>rand()%absorbChanceDenom)
{ {
parts[i].life++; parts[i].life++;
sim->create_part(r>>8, x+rx, y+ry, PT_CLST); sim->create_part(ID(r), x+rx, y+ry, PT_CLST);
} }
break; break;
default: default:
@ -119,18 +119,18 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_SPNG&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion if ((r&0xFF)==PT_SPNG&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion
{ {
tmp = parts[i].life - parts[r>>8].life; tmp = parts[i].life - parts[ID(r)].life;
if (tmp ==1) if (tmp ==1)
{ {
parts[r>>8].life ++; parts[ID(r)].life ++;
parts[i].life --; parts[i].life --;
trade = 9; trade = 9;
} }
else if (tmp>0) else if (tmp>0)
{ {
parts[r>>8].life += tmp/2; parts[ID(r)].life += tmp/2;
parts[i].life -= tmp/2; parts[i].life -= tmp/2;
trade = 9; trade = 9;
} }
@ -150,10 +150,10 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
if ((r&0xFF)==PT_FIRE) if ((r&0xFF)==PT_FIRE)
{ {
tmp++; tmp++;
if (parts[r>>8].life>60) if (parts[ID(r)].life>60)
parts[r>>8].life -= parts[r>>8].life/60; parts[ID(r)].life -= parts[ID(r)].life/60;
else if (parts[r>>8].life>2) else if (parts[ID(r)].life>2)
parts[r>>8].life--; parts[ID(r)].life--;
} }
} }
} }

View File

@ -152,9 +152,9 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
{ {
int rnd = rand()%100; int rnd = rand()%100;
if (!rnd) if (!rnd)
sim->part_change_type(r>>8,x+rx,y+ry,PT_O2); sim->part_change_type(ID(r),x+rx,y+ry,PT_O2);
else if (3>rnd) else if (3>rnd)
sim->part_change_type(r>>8,x+rx,y+ry,PT_H2); sim->part_change_type(ID(r),x+rx,y+ry,PT_H2);
} }
} }
break; break;
@ -174,7 +174,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
continue; continue;
receiver = r&0xFF; receiver = r&0xFF;
sender = ct; sender = ct;
pavg = sim->parts_avg(r>>8, i,PT_INSL); pavg = sim->parts_avg(ID(r), i,PT_INSL);
//receiver is the element SPRK is trying to conduct to //receiver is the element SPRK is trying to conduct to
//sender is the element the SPRK is on //sender is the element the SPRK is on
//First, some checks usually for (de)activation of elements //First, some checks usually for (de)activation of elements
@ -183,47 +183,47 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
case PT_SWCH: case PT_SWCH:
if (pavg!=PT_INSL && parts[i].life<4) if (pavg!=PT_INSL && parts[i].life<4)
{ {
if(sender==PT_PSCN && parts[r>>8].life<10) { if(sender==PT_PSCN && parts[ID(r)].life<10) {
parts[r>>8].life = 10; parts[ID(r)].life = 10;
} }
else if (sender==PT_NSCN) else if (sender==PT_NSCN)
{ {
parts[r>>8].ctype = PT_NONE; parts[ID(r)].ctype = PT_NONE;
parts[r>>8].life = 9; parts[ID(r)].life = 9;
} }
} }
break; break;
case PT_SPRK: case PT_SPRK:
if (pavg!=PT_INSL && parts[i].life<4) if (pavg!=PT_INSL && parts[i].life<4)
{ {
if (parts[r>>8].ctype==PT_SWCH) if (parts[ID(r)].ctype==PT_SWCH)
{ {
if (sender==PT_NSCN) if (sender==PT_NSCN)
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_SWCH); sim->part_change_type(ID(r),x+rx,y+ry,PT_SWCH);
parts[r>>8].ctype = PT_NONE; parts[ID(r)].ctype = PT_NONE;
parts[r>>8].life = 9; parts[ID(r)].life = 9;
} }
} }
else if(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT) else if(parts[ID(r)].ctype==PT_NTCT||parts[ID(r)].ctype==PT_PTCT)
if (sender==PT_METL) if (sender==PT_METL)
{ {
parts[r>>8].temp = 473.0f; parts[ID(r)].temp = 473.0f;
} }
} }
continue; continue;
case PT_PUMP: case PT_GPMP: case PT_HSWC: case PT_PBCN: case PT_PUMP: case PT_GPMP: case PT_HSWC: case PT_PBCN:
if (parts[i].life<4)// PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves if (parts[i].life<4)// PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves
{ {
if (sender==PT_PSCN) parts[r>>8].life = 10; if (sender==PT_PSCN) parts[ID(r)].life = 10;
else if (sender==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9; else if (sender==PT_NSCN && parts[ID(r)].life>=10) parts[ID(r)].life = 9;
} }
continue; continue;
case PT_LCRY: case PT_LCRY:
if (abs(rx)<2&&abs(ry)<2 && parts[i].life<4) if (abs(rx)<2&&abs(ry)<2 && parts[i].life<4)
{ {
if (sender==PT_PSCN && parts[r>>8].tmp == 0) parts[r>>8].tmp = 2; if (sender==PT_PSCN && parts[ID(r)].tmp == 0) parts[ID(r)].tmp = 2;
else if (sender==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1; else if (sender==PT_NSCN && parts[ID(r)].tmp == 3) parts[ID(r)].tmp = 1;
} }
continue; continue;
case PT_PPIP: case PT_PPIP:
@ -236,19 +236,19 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
case PT_NTCT: case PT_PTCT: case PT_INWR: case PT_NTCT: case PT_PTCT: case PT_INWR:
if (sender==PT_METL && pavg!=PT_INSL && parts[i].life<4) if (sender==PT_METL && pavg!=PT_INSL && parts[i].life<4)
{ {
parts[r>>8].temp = 473.0f; parts[ID(r)].temp = 473.0f;
if (receiver==PT_NTCT||receiver==PT_PTCT) if (receiver==PT_NTCT||receiver==PT_PTCT)
continue; continue;
} }
break; break;
case PT_EMP: case PT_EMP:
if (!parts[r>>8].life && parts[i].life > 0 && parts[i].life < 4) if (!parts[ID(r)].life && parts[i].life > 0 && parts[i].life < 4)
{ {
sim->emp_trigger_count++; sim->emp_trigger_count++;
sim->emp_decor += 3; sim->emp_decor += 3;
if (sim->emp_decor > 40) if (sim->emp_decor > 40)
sim->emp_decor = 40; sim->emp_decor = 40;
parts[r>>8].life = 220; parts[ID(r)].life = 220;
} }
continue; continue;
} }
@ -292,15 +292,15 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
switch (receiver) switch (receiver)
{ {
case PT_QRTZ: case PT_QRTZ:
if ((sender==PT_NSCN||sender==PT_METL||sender==PT_PSCN||sender==PT_QRTZ) && (parts[r>>8].temp<173.15||sim->pv[(y+ry)/CELL][(x+rx)/CELL]>8)) if ((sender==PT_NSCN||sender==PT_METL||sender==PT_PSCN||sender==PT_QRTZ) && (parts[ID(r)].temp<173.15||sim->pv[(y+ry)/CELL][(x+rx)/CELL]>8))
goto conduct; goto conduct;
continue; continue;
case PT_NTCT: case PT_NTCT:
if (sender==PT_NSCN || (sender==PT_PSCN&&parts[r>>8].temp>373.0f)) if (sender==PT_NSCN || (sender==PT_PSCN&&parts[ID(r)].temp>373.0f))
goto conduct; goto conduct;
continue; continue;
case PT_PTCT: case PT_PTCT:
if (sender==PT_NSCN || (sender==PT_PSCN&&parts[r>>8].temp<373.0f)) if (sender==PT_NSCN || (sender==PT_PSCN&&parts[ID(r)].temp<373.0f))
goto conduct; goto conduct;
continue; continue;
case PT_INWR: case PT_INWR:
@ -325,35 +325,35 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
conduct: conduct:
//Yay, passed normal conduction rules, check a few last things and change receiver to spark //Yay, passed normal conduction rules, check a few last things and change receiver to spark
if (receiver==PT_WATR||receiver==PT_SLTW) { if (receiver==PT_WATR||receiver==PT_SLTW) {
if (parts[r>>8].life==0 && parts[i].life<3) if (parts[ID(r)].life==0 && parts[i].life<3)
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
if (receiver==PT_WATR) parts[r>>8].life = 6; if (receiver==PT_WATR) parts[ID(r)].life = 6;
else parts[r>>8].life = 5; else parts[ID(r)].life = 5;
parts[r>>8].ctype = receiver; parts[ID(r)].ctype = receiver;
} }
} }
else if (receiver==PT_INST) { else if (receiver==PT_INST) {
if (parts[r>>8].life==0 && parts[i].life<4) if (parts[ID(r)].life==0 && parts[i].life<4)
{ {
sim->FloodINST(x+rx,y+ry,PT_SPRK,PT_INST);//spark the wire sim->FloodINST(x+rx,y+ry,PT_SPRK,PT_INST);//spark the wire
} }
} }
else if (parts[r>>8].life==0 && parts[i].life<4) { else if (parts[ID(r)].life==0 && parts[i].life<4) {
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = receiver; parts[ID(r)].ctype = receiver;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
if (parts[r>>8].temp+10.0f<673.0f&&!sim->legacy_enable&&(receiver==PT_METL||receiver==PT_BMTL||receiver==PT_BRMT||receiver==PT_PSCN||receiver==PT_NSCN||receiver==PT_ETRD||receiver==PT_NBLE||receiver==PT_IRON)) if (parts[ID(r)].temp+10.0f<673.0f&&!sim->legacy_enable&&(receiver==PT_METL||receiver==PT_BMTL||receiver==PT_BRMT||receiver==PT_PSCN||receiver==PT_NSCN||receiver==PT_ETRD||receiver==PT_NBLE||receiver==PT_IRON))
parts[r>>8].temp = parts[r>>8].temp+10.0f; parts[ID(r)].temp = parts[ID(r)].temp+10.0f;
} }
else if (!parts[r>>8].life && sender==PT_ETRD && parts[i].life==5) //ETRD is odd and conducts to others only at life 5, this could probably be somewhere else else if (!parts[ID(r)].life && sender==PT_ETRD && parts[i].life==5) //ETRD is odd and conducts to others only at life 5, this could probably be somewhere else
{ {
sim->part_change_type(i,x,y,sender); sim->part_change_type(i,x,y,sender);
parts[i].ctype = PT_NONE; parts[i].ctype = PT_NONE;
parts[i].life = 20; parts[i].life = 20;
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = receiver; parts[ID(r)].ctype = receiver;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
} }
} }
return 0; return 0;

View File

@ -375,14 +375,14 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
parts[i].life += 5; parts[i].life += 5;
else else
parts[i].life = 100; parts[i].life = 100;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
if ((r&0xFF) == PT_NEUT) if ((r&0xFF) == PT_NEUT)
{ {
if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2; if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2;
else parts[i].life *= 0.9f; else parts[i].life *= 0.9f;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN) if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN)
playerp->elem = SPC_AIR; playerp->elem = SPC_AIR;
@ -583,7 +583,7 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
sim->parts[i].life -= (int)(rand()*20/RAND_MAX)+32; sim->parts[i].life -= (int)(rand()*20/RAND_MAX)+32;
} }
if (sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||sim->parts[r>>8].life==10) && ((playerp->elem!=PT_LIGH && sim->parts[r>>8].temp>=323) || sim->parts[r>>8].temp<=243) && (!playerp->rocketBoots || (r&0xFF)!=PT_PLSM)) if (sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||sim->parts[ID(r)].life==10) && ((playerp->elem!=PT_LIGH && sim->parts[ID(r)].temp>=323) || sim->parts[ID(r)].temp<=243) && (!playerp->rocketBoots || (r&0xFF)!=PT_PLSM))
{ {
sim->parts[i].life -= 2; sim->parts[i].life -= 2;
playerp->accs[3] -= 1; playerp->accs[3] -= 1;
@ -606,17 +606,17 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
if ((r&0xFF)==PT_PRTI && sim->parts[i].type) if ((r&0xFF)==PT_PRTI && sim->parts[i].type)
{ {
int nnx, count=1;//gives rx=0, ry=1 in update_PRTO int nnx, count=1;//gives rx=0, ry=1 in update_PRTO
sim->parts[r>>8].tmp = (int)((sim->parts[r>>8].temp-73.15f)/100+1); sim->parts[ID(r)].tmp = (int)((sim->parts[ID(r)].temp-73.15f)/100+1);
if (sim->parts[r>>8].tmp>=CHANNELS) sim->parts[r>>8].tmp = CHANNELS-1; if (sim->parts[ID(r)].tmp>=CHANNELS) sim->parts[ID(r)].tmp = CHANNELS-1;
else if (sim->parts[r>>8].tmp<0) sim->parts[r>>8].tmp = 0; else if (sim->parts[ID(r)].tmp<0) sim->parts[ID(r)].tmp = 0;
for (nnx=0; nnx<80; nnx++) for (nnx=0; nnx<80; nnx++)
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type) if (!sim->portalp[sim->parts[ID(r)].tmp][count][nnx].type)
{ {
sim->portalp[sim->parts[r>>8].tmp][count][nnx] = sim->parts[i]; sim->portalp[sim->parts[ID(r)].tmp][count][nnx] = sim->parts[i];
sim->kill_part(i); sim->kill_part(i);
//stop new STKM/fighters being created to replace the ones in the portal: //stop new STKM/fighters being created to replace the ones in the portal:
playerp->spwn = 1; playerp->spwn = 1;
if (sim->portalp[sim->parts[r>>8].tmp][count][nnx].type==PT_FIGH) if (sim->portalp[sim->parts[ID(r)].tmp][count][nnx].type==PT_FIGH)
sim->fighcount++; sim->fighcount++;
break; break;
} }
@ -625,11 +625,11 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
{ {
if (!sim->legacy_enable) if (!sim->legacy_enable)
{ {
sim->parts[r>>8].temp = restrict_flt(sim->parts[r>>8].temp+sim->parts[i].temp/2, MIN_TEMP, MAX_TEMP); sim->parts[ID(r)].temp = restrict_flt(sim->parts[ID(r)].temp+sim->parts[i].temp/2, MIN_TEMP, MAX_TEMP);
} }
sim->kill_part(i); sim->kill_part(i);
} }
if (((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && sim->parts[r>>8].life==10)) && (!sim->parts[r>>8].ctype || (sim->parts[r>>8].ctype==sim->parts[i].type)!=(sim->parts[r>>8].tmp&1)) && sim->parts[i].type) if (((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && sim->parts[ID(r)].life==10)) && (!sim->parts[ID(r)].ctype || (sim->parts[ID(r)].ctype==sim->parts[i].type)!=(sim->parts[ID(r)].tmp&1)) && sim->parts[i].type)
{ {
sim->kill_part(i); sim->kill_part(i);
} }

View File

@ -58,20 +58,20 @@ int Element_STOR::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r) if ((ID(r))>=NPART || !r)
continue; continue;
if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(sim->elements[(r&0xFF)].Properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype)) if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(sim->elements[(r&0xFF)].Properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype))
{ {
if ((r&0xFF) == PT_SOAP) if ((r&0xFF) == PT_SOAP)
Element_SOAP::detach(sim, r>>8); Element_SOAP::detach(sim, ID(r));
parts[i].tmp = parts[r>>8].type; parts[i].tmp = parts[ID(r)].type;
parts[i].temp = parts[r>>8].temp; parts[i].temp = parts[ID(r)].temp;
parts[i].tmp2 = parts[r>>8].life; parts[i].tmp2 = parts[ID(r)].life;
parts[i].pavg[0] = parts[r>>8].tmp; parts[i].pavg[0] = parts[ID(r)].tmp;
parts[i].pavg[1] = parts[r>>8].ctype; parts[i].pavg[1] = parts[ID(r)].ctype;
sim->kill_part(r>>8); sim->kill_part(ID(r));
} }
if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN && parts[r>>8].life>0 && parts[r>>8].life<4) if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[ID(r)].ctype==PT_PSCN && parts[ID(r)].life>0 && parts[ID(r)].life<4)
{ {
for(ry1 = 1; ry1 >= -1; ry1--){ for(ry1 = 1; ry1 >= -1; ry1--){
for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscillate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1) for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscillate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1)

View File

@ -63,19 +63,19 @@ int Element_SWCH::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if (sim->parts_avg(i,r>>8,PT_INSL)!=PT_INSL) { if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL) {
rt = r&0xFF; rt = r&0xFF;
if (rt==PT_SWCH) if (rt==PT_SWCH)
{ {
if (parts[i].life>=10&&parts[r>>8].life<10&&parts[r>>8].life>0) if (parts[i].life>=10&&parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[i].life==0&&parts[r>>8].life>=10) else if (parts[i].life==0&&parts[ID(r)].life>=10)
{ {
//Set to other particle's life instead of 10, otherwise spark loops form when SWCH is sparked while turning on //Set to other particle's life instead of 10, otherwise spark loops form when SWCH is sparked while turning on
parts[i].life = parts[r>>8].life; parts[i].life = parts[ID(r)].life;
} }
} }
else if (rt==PT_SPRK && parts[i].life==10 && parts[r>>8].life>0 && parts[r>>8].ctype!=PT_PSCN && parts[r>>8].ctype!=PT_NSCN) { else if (rt==PT_SPRK && parts[i].life==10 && parts[ID(r)].life>0 && parts[ID(r)].ctype!=PT_PSCN && parts[ID(r)].ctype!=PT_NSCN) {
sim->part_change_type(i,x,y,PT_SPRK); sim->part_change_type(i,x,y,PT_SPRK);
parts[i].ctype = PT_SWCH; parts[i].ctype = PT_SWCH;
parts[i].life = 4; parts[i].life = 4;

View File

@ -58,11 +58,11 @@ int Element_THDR::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = r&0xFF;
if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !(rt==PT_WATR||rt==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK) if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0 && !(rt==PT_WATR||rt==PT_SLTW) && parts[ID(r)].ctype!=PT_SPRK)
{ {
parts[r>>8].ctype = parts[r>>8].type; parts[ID(r)].ctype = parts[ID(r)].type;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
parts[r>>8].life = 4; parts[ID(r)].life = 4;
kill=true; kill=true;
} }
else if (rt!=PT_CLNE&&rt!=PT_THDR&&rt!=PT_SPRK&&rt!=PT_DMND&&rt!=PT_FIRE) else if (rt!=PT_CLNE&&rt!=PT_THDR&&rt!=PT_SPRK&&rt!=PT_DMND&&rt!=PT_FIRE)

View File

@ -258,9 +258,9 @@ int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, in
//#TPT-Directive ElementHeader Element_TRON static bool canmovetron(Simulation * sim, int r, int len) //#TPT-Directive ElementHeader Element_TRON static bool canmovetron(Simulation * sim, int r, int len)
bool Element_TRON::canmovetron(Simulation * sim, int r, int len) bool Element_TRON::canmovetron(Simulation * sim, int r, int len)
{ {
if (!r || ((r&0xFF) == PT_SWCH && sim->parts[r>>8].life >= 10) || ((r&0xFF) == PT_INVIS && sim->parts[r>>8].tmp2 == 1)) if (!r || ((r&0xFF) == PT_SWCH && sim->parts[ID(r)].life >= 10) || ((r&0xFF) == PT_INVIS && sim->parts[ID(r)].tmp2 == 1))
return true; return true;
if ((((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL_DEC) && sim->parts[r>>8].life > 0)|| ((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL) && (sim->elements[r&0xFF].Properties & PROP_LIFE_DEC))) && sim->parts[r>>8].life < len) if ((((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL_DEC) && sim->parts[ID(r)].life > 0)|| ((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL) && (sim->elements[r&0xFF].Properties & PROP_LIFE_DEC))) && sim->parts[ID(r)].life < len)
return true; return true;
return false; return false;
} }

View File

@ -61,13 +61,13 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
int rt = r&0xFF; int rt = r&0xFF;
if (sim->parts_avg(i, r>>8, PT_INSL) != PT_INSL) if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL)
{ {
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[r>>8].life == 0) if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0)
{ {
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = rt; parts[ID(r)].ctype = rt;
sim->part_change_type(r>>8, x+rx, y+ry, PT_SPRK); sim->part_change_type(ID(r), x+rx, y+ry, PT_SPRK);
} }
} }
} }
@ -83,12 +83,12 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF) != PT_TSNS && (r&0xFF) != PT_METL && parts[r>>8].temp > parts[i].temp) if ((r&0xFF) != PT_TSNS && (r&0xFF) != PT_METL && parts[ID(r)].temp > parts[i].temp)
parts[i].life = 1; parts[i].life = 1;
if (parts[i].tmp == 1 && (r&0xFF) != PT_TSNS && (r&0xFF) != PT_FILT) if (parts[i].tmp == 1 && (r&0xFF) != PT_TSNS && (r&0xFF) != PT_FILT)
{ {
setFilt = true; setFilt = true;
photonWl = parts[r>>8].temp; photonWl = parts[ID(r)].temp;
} }
} }
if (setFilt) if (setFilt)
@ -105,7 +105,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS)
ny = y + ry; ny = y + ry;
while ((r & 0xFF) == PT_FILT) while ((r & 0xFF) == PT_FILT)
{ {
parts[r>>8].ctype = 0x10000000 + photonWl; parts[ID(r)].ctype = 0x10000000 + photonWl;
nx += rx; nx += rx;
ny += ry; ny += ry;
if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES) if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES)

View File

@ -87,11 +87,11 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
ry = (rndstore>>2)%3-1; ry = (rndstore>>2)%3-1;
rndstore = rndstore >> 4; rndstore = rndstore >> 4;
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if ((r&0xFF) && (r&0xFF) != PT_BREC && (sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && !parts[r>>8].life) if ((r&0xFF) && (r&0xFF) != PT_BREC && (sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && !parts[ID(r)].life)
{ {
parts[r>>8].life = 4; parts[ID(r)].life = 4;
parts[r>>8].ctype = r&0xFF; parts[ID(r)].ctype = r&0xFF;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
} }
} }
//Release all heat //Release all heat
@ -102,9 +102,9 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
if(BOUNDS_CHECK) if(BOUNDS_CHECK)
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if ((r&0xFF) && (r&0xFF)!=PT_VIBR && (r&0xFF)!=PT_BVBR && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10)) if ((r&0xFF) && (r&0xFF)!=PT_VIBR && (r&0xFF)!=PT_BVBR && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[ID(r)].life==10))
{ {
parts[r>>8].temp += parts[i].tmp*3; parts[ID(r)].temp += parts[i].tmp*3;
parts[i].tmp = 0; parts[i].tmp = 0;
} }
} }
@ -154,11 +154,11 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
//Makes EXOT around it get tmp to start exploding too //Makes EXOT around it get tmp to start exploding too
if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR)) if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR))
{ {
if (!parts[r>>8].life) if (!parts[ID(r)].life)
parts[r>>8].tmp += 45; parts[ID(r)].tmp += 45;
else if (parts[i].tmp2 && parts[i].life > 75 && rand()%2) else if (parts[i].tmp2 && parts[i].life > 75 && rand()%2)
{ {
parts[r>>8].tmp2 = 1; parts[ID(r)].tmp2 = 1;
parts[i].tmp = 0; parts[i].tmp = 0;
} }
} }
@ -197,10 +197,10 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if ((r&0xFF) != PT_VIBR && (r&0xFF) != PT_BVBR) if ((r&0xFF) != PT_VIBR && (r&0xFF) != PT_BVBR)
continue; continue;
if (parts[i].tmp > parts[r>>8].tmp) if (parts[i].tmp > parts[ID(r)].tmp)
{ {
transfer = parts[i].tmp - parts[r>>8].tmp; transfer = parts[i].tmp - parts[ID(r)].tmp;
parts[r>>8].tmp += transfer/2; parts[ID(r)].tmp += transfer/2;
parts[i].tmp -= transfer/2; parts[i].tmp -= transfer/2;
break; break;
} }

View File

@ -86,9 +86,9 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
continue; continue;
//spread "being cured" state //spread "being cured" state
if (parts[r>>8].pavg[0] && ((r&0xFF) == PT_VIRS || (r&0xFF) == PT_VRSS || (r&0xFF) == PT_VRSG)) if (parts[ID(r)].pavg[0] && ((r&0xFF) == PT_VIRS || (r&0xFF) == PT_VRSS || (r&0xFF) == PT_VRSG))
{ {
parts[i].pavg[0] = parts[r>>8].pavg[0] + ((rndstore & 0x3) ? 2:1); parts[i].pavg[0] = parts[ID(r)].pavg[0] + ((rndstore & 0x3) ? 2:1);
return 0; return 0;
} }
//soap cures virus //soap cures virus
@ -96,7 +96,7 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
{ {
parts[i].pavg[0] += 10; parts[i].pavg[0] += 10;
if (!(rndstore & 0x3)) if (!(rndstore & 0x3))
sim->kill_part(r>>8); sim->kill_part(ID(r));
return 0; return 0;
} }
else if ((r&0xFF) == PT_PLSM) else if ((r&0xFF) == PT_PLSM)
@ -112,18 +112,18 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
{ {
if (!(rndstore & 0x7)) if (!(rndstore & 0x7))
{ {
parts[r>>8].tmp2 = (r&0xFF); parts[ID(r)].tmp2 = (r&0xFF);
parts[r>>8].pavg[0] = 0; parts[ID(r)].pavg[0] = 0;
if (parts[i].pavg[1]) if (parts[i].pavg[1])
parts[r>>8].pavg[1] = parts[i].pavg[1] + 1; parts[ID(r)].pavg[1] = parts[i].pavg[1] + 1;
else else
parts[r>>8].pavg[1] = 0; parts[ID(r)].pavg[1] = 0;
if (parts[r>>8].temp < 305.0f) if (parts[ID(r)].temp < 305.0f)
sim->part_change_type(r>>8, x+rx, y+ry, PT_VRSS); sim->part_change_type(ID(r), x+rx, y+ry, PT_VRSS);
else if (parts[r>>8].temp > 673.0f) else if (parts[ID(r)].temp > 673.0f)
sim->part_change_type(r>>8, x+rx, y+ry, PT_VRSG); sim->part_change_type(ID(r), x+rx, y+ry, PT_VRSG);
else else
sim->part_change_type(r>>8, x+rx, y+ry, PT_VIRS); sim->part_change_type(ID(r), x+rx, y+ry, PT_VIRS);
} }
rndstore >>= 3; rndstore >>= 3;
} }

View File

@ -67,12 +67,12 @@ int Element_WARP::update(UPDATE_FUNC_ARGS)
continue; continue;
if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN) if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN)
{ {
parts[i].x = parts[r>>8].x; parts[i].x = parts[ID(r)].x;
parts[i].y = parts[r>>8].y; parts[i].y = parts[ID(r)].y;
parts[r>>8].x = x; parts[ID(r)].x = x;
parts[r>>8].y = y; parts[ID(r)].y = y;
parts[r>>8].vx = (rand()%4)-1.5; parts[ID(r)].vx = (rand()%4)-1.5;
parts[r>>8].vy = (rand()%4)-2; parts[ID(r)].vy = (rand()%4)-2;
parts[i].life += 4; parts[i].life += 4;
pmap[y][x] = r; pmap[y][x] = r;
pmap[y+ry][x+rx] = (i<<8)|parts[i].type; pmap[y+ry][x+rx] = (i<<8)|parts[i].type;

View File

@ -60,7 +60,7 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 WATR to SLTW before SALT turns into SLTW // on average, convert 3 WATR to SLTW before SALT turns into SLTW
if (!(rand()%3)) if (!(rand()%3))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
} }
else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100)) else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100))
{ {
@ -68,8 +68,8 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
parts[i].life = 4; parts[i].life = 4;
parts[i].ctype = PT_WATR; parts[i].ctype = PT_WATR;
} }
else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ else if ((r&0xFF)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){
sim->kill_part(r>>8); sim->kill_part(ID(r));
if(!(rand()%30)){ if(!(rand()%30)){
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
@ -82,7 +82,7 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
/*if ((r&0xFF)==PT_CNCT && !(rand()%100)) Concrete+Water to paste, not very popular /*if ((r&0xFF)==PT_CNCT && !(rand()%100)) Concrete+Water to paste, not very popular
{ {
part_change_type(i,x,y,PT_PSTE); part_change_type(i,x,y,PT_PSTE);
sim.kill_part(r>>8); sim.kill_part(ID(r));
}*/ }*/
} }
return 0; return 0;

Some files were not shown because too many files have changed in this diff Show More