diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 9e8e68eb5..6a6ebaf43 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -97,7 +97,7 @@ Client::Client(): std::string SessionKey = preferences["User"]["SessionKey"].asString(); std::string Elevation = preferences["User"]["Elevation"].asString(); - authUser.ID = ID; + authUser.UserID = ID; authUser.Username = Username; authUser.SessionID = SessionID; authUser.SessionKey = SessionKey; @@ -149,9 +149,9 @@ void Client::Initialise(std::string proxyString) //Begin version check versionCheckRequest = http_async_req_start(NULL, "http://" SERVER "/Startup.json", NULL, 0, 0); - if (authUser.ID) + if (authUser.UserID) { - std::string idTempString = format::NumberToString(authUser.ID); + std::string idTempString = format::NumberToString(authUser.UserID); char *id = new char[idTempString.length() + 1]; std::strcpy (id, idTempString.c_str()); char *session = new char[authUser.SessionID.length() + 1]; @@ -945,9 +945,9 @@ void Client::WritePrefs() 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"]["SessionKey"] = authUser.SessionKey; preferences["User"]["Username"] = authUser.Username; @@ -1003,8 +1003,8 @@ RequestStatus Client::UploadSave(SaveInfo & save) char * data; int dataLength = 0; std::stringstream userIDStream; - userIDStream << authUser.ID; - if (authUser.ID) + userIDStream << authUser.UserID; + if (authUser.UserID) { if (!save.GetGameSave()) { @@ -1244,11 +1244,11 @@ RequestStatus Client::ExecVote(int saveID, int direction) char * data; int dataLength = 0; - if (authUser.ID) + if (authUser.UserID) { char * directionText = (char*)(direction==1?"Up":"Down"); std::string saveIDText = format::NumberToString(saveID); - std::string userIDText = format::NumberToString(authUser.ID); + std::string userIDText = format::NumberToString(authUser.UserID); char *id = new char[saveIDText.length() + 1]; 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 totalHash[33]; - user.ID = 0; + user.UserID = 0; user.Username = ""; user.SessionID = ""; user.SessionKey = ""; @@ -1443,7 +1443,7 @@ LoginStatus Client::Login(std::string username, std::string password, User & use } user.Username = username; - user.ID = userIDTemp; + user.UserID = userIDTemp; user.SessionID = sessionIDTemp; user.SessionKey = sessionKeyTemp; std::string userElevation = userElevationTemp; @@ -1472,10 +1472,10 @@ RequestStatus Client::DeleteSave(int saveID) char * data = NULL; int dataStatus, dataLength; urlStream << "http://" << SERVER << "/Browse/Delete.json?ID=" << saveID << "&Mode=Delete&Key=" << authUser.SessionKey; - if(authUser.ID) + if(authUser.UserID) { 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); } else @@ -1495,10 +1495,10 @@ RequestStatus Client::AddComment(int saveID, std::string comment) char * data = NULL; int dataStatus, dataLength; urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID; - if(authUser.ID) + if(authUser.UserID) { std::stringstream userIDStream; - userIDStream << authUser.ID; + userIDStream << authUser.UserID; const char *const postNames[] = { "Comment", NULL }; 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; if(!favourite) urlStream << "&Mode=Remove"; - if(authUser.ID) + if(authUser.UserID) { 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); } else @@ -1547,10 +1547,10 @@ RequestStatus Client::ReportSave(int saveID, std::string message) char * data = NULL; int dataStatus, dataLength; urlStream << "http://" << SERVER << "/Browse/Report.json?ID=" << saveID << "&Key=" << authUser.SessionKey; - if(authUser.ID) + if(authUser.UserID) { std::stringstream userIDStream; - userIDStream << authUser.ID; + userIDStream << authUser.UserID; const char *const postNames[] = { "Reason", NULL }; const char *const postDatas[] = { (char*)(message.c_str()) }; @@ -1574,10 +1574,10 @@ RequestStatus Client::UnpublishSave(int saveID) char * data = NULL; int dataStatus, dataLength; urlStream << "http://" << SERVER << "/Browse/Delete.json?ID=" << saveID << "&Mode=Unpublish&Key=" << authUser.SessionKey; - if(authUser.ID) + if(authUser.UserID) { 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); } else @@ -1597,10 +1597,10 @@ RequestStatus Client::PublishSave(int saveID) char *data; int dataStatus; urlStream << "http://" << SERVER << "/Browse/View.json?ID=" << saveID << "&Key=" << authUser.SessionKey; - if (authUser.ID) + if (authUser.UserID) { std::stringstream userIDStream; - userIDStream << authUser.ID; + userIDStream << authUser.UserID; const char *const postNames[] = { "ActionPublish", NULL }; const char *const postDatas[] = { "" }; size_t postLengths[] = { 1 }; @@ -1626,10 +1626,10 @@ SaveInfo * Client::GetSave(int saveID, int saveDate) } char * data; int dataStatus, dataLength; - if(authUser.ID) + if(authUser.UserID) { 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); } else @@ -1866,10 +1866,10 @@ std::vector * Client::SearchSaves(int start, int count, std::string q { urlStream << "&Category=" << format::URLEncode(category); } - if(authUser.ID) + if(authUser.UserID) { 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); } else @@ -1935,10 +1935,10 @@ std::list * Client::RemoveTag(int saveID, std::string tag) char * data = NULL; int dataStatus, dataLength; urlStream << "http://" << SERVER << "/Browse/EditTag.json?Op=delete&ID=" << saveID << "&Tag=" << tag << "&Key=" << authUser.SessionKey; - if(authUser.ID) + if(authUser.UserID) { 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); } else @@ -1977,10 +1977,10 @@ std::list * Client::AddTag(int saveID, std::string tag) char * data = NULL; int dataStatus, dataLength; urlStream << "http://" << SERVER << "/Browse/EditTag.json?Op=add&ID=" << saveID << "&Tag=" << tag << "&Key=" << authUser.SessionKey; - if(authUser.ID) + if(authUser.UserID) { 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); } else diff --git a/src/client/User.h b/src/client/User.h index 5dfb5315b..3bc8f926c 100644 --- a/src/client/User.h +++ b/src/client/User.h @@ -11,13 +11,13 @@ public: { ElevationAdmin, ElevationModerator, ElevationNone }; - int ID; + int UserID; std::string Username; std::string SessionID; std::string SessionKey; Elevation UserElevation; User(int id, std::string username): - ID(id), + UserID(id), Username(username), SessionID(""), SessionKey(""), diff --git a/src/client/UserInfo.h b/src/client/UserInfo.h index 034c18e9b..0c808a7a4 100644 --- a/src/client/UserInfo.h +++ b/src/client/UserInfo.h @@ -6,7 +6,7 @@ class UserInfo { public: - int ID; + int UserID; int age; std::string username; std::string biography; @@ -22,7 +22,7 @@ public: 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), username(username), biography(biography), diff --git a/src/client/requestbroker/APIRequest.cpp b/src/client/requestbroker/APIRequest.cpp index a1a028a4e..f60f56ac5 100644 --- a/src/client/requestbroker/APIRequest.cpp +++ b/src/client/requestbroker/APIRequest.cpp @@ -98,12 +98,12 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb) } postNames[i] = NULL; - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { User user = Client::Ref().GetAuthUser(); char userName[12]; char *userSession = new char[user.SessionID.length() + 1]; - std::strcpy(userName, format::NumberToString(user.ID).c_str()); + std::strcpy(userName, format::NumberToString(user.UserID).c_str()); std::strcpy(userSession, user.SessionID.c_str()); HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession); delete[] userSession; @@ -117,12 +117,12 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb) else { 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(); char userName[12]; char *userSession = new char[user.SessionID.length() + 1]; - std::strcpy(userName, format::NumberToString(user.ID).c_str()); + std::strcpy(userName, format::NumberToString(user.UserID).c_str()); std::strcpy(userSession, user.SessionID.c_str()); http_auth_headers(HTTPContext, userName, NULL, userSession); delete[] userSession; diff --git a/src/client/requestbroker/WebRequest.cpp b/src/client/requestbroker/WebRequest.cpp index fb5efcd86..694a95eb0 100644 --- a/src/client/requestbroker/WebRequest.cpp +++ b/src/client/requestbroker/WebRequest.cpp @@ -98,7 +98,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb) } postNames[i] = NULL; - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { #ifdef DEBUG std::cout << typeid(*this).name() << " Authenticated " << std::endl; @@ -106,7 +106,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb) User user = Client::Ref().GetAuthUser(); char userName[12]; char *userSession = new char[user.SessionID.length() + 1]; - std::strcpy(userName, format::NumberToString(user.ID).c_str()); + std::strcpy(userName, format::NumberToString(user.UserID).c_str()); std::strcpy(userSession, user.SessionID.c_str()); HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession); delete[] userSession; @@ -120,12 +120,12 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb) else { 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(); char userName[12]; char *userSession = new char[user.SessionID.length() + 1]; - std::strcpy(userName, format::NumberToString(user.ID).c_str()); + std::strcpy(userName, format::NumberToString(user.UserID).c_str()); std::strcpy(userSession, user.SessionID.c_str()); http_auth_headers(HTTPContext, userName, NULL, userSession); delete[] userSession; diff --git a/src/debug/DebugInfo.h b/src/debug/DebugInfo.h index 0cb3c205f..2414bd669 100644 --- a/src/debug/DebugInfo.h +++ b/src/debug/DebugInfo.h @@ -6,9 +6,9 @@ class DebugInfo { public: - DebugInfo(unsigned int id):ID(id) { } + DebugInfo(unsigned int id):debugID(id) { } virtual ~DebugInfo() { } - unsigned int ID; + unsigned int debugID; virtual void Draw() {} // 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; } diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 356949a99..1238ea972 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -775,7 +775,7 @@ bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl, for(std::vector::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())) ret = false; } @@ -842,7 +842,7 @@ void GameController::Tick() } for(std::vector::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) { - if ((*iter)->ID & debugFlags) + if ((*iter)->debugID & debugFlags) (*iter)->Draw(); } commandInterface->OnTick(); @@ -1301,7 +1301,7 @@ void GameController::OpenLogin() void GameController::OpenProfile() { - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { new ProfileActivity(Client::Ref().GetAuthUser().Username); } @@ -1408,7 +1408,7 @@ void GameController::OpenSaveWindow() c->LoadSave(&save); } }; - if(gameModel->GetUser().ID) + if(gameModel->GetUser().UserID) { Simulation * sim = gameModel->GetSimulation(); 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(); GameSave * gameSave = sim->Save(); @@ -1481,7 +1481,7 @@ void GameController::SaveAsCurrent() } } } - else if(gameModel->GetUser().ID) + else if(gameModel->GetUser().UserID) { OpenSaveWindow(); } @@ -1499,7 +1499,7 @@ void GameController::FrameStep() 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 { diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index c250f7533..d50b99a95 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -92,7 +92,7 @@ GameModel::GameModel(): Favorite::Ref().LoadFavoritesFromPrefs(); //Load last user - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { currentUser = Client::Ref().GetAuthUser(); } diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 861158e8a..81f4d9952 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -265,14 +265,14 @@ GameView::GameView(): SaveSimulationAction(GameView * _v) { v = _v; } void ActionCallbackRight(ui::Button * sender) { - if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().ID) + if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().UserID) v->c->OpenLocalSaveWindow(false); else v->c->OpenSaveWindow(); } void ActionCallbackLeft(ui::Button * sender) { - if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().ID) + if(v->CtrlBehaviour() || !Client::Ref().GetAuthUser().UserID) v->c->OpenLocalSaveWindow(true); else v->c->SaveAsCurrent(); @@ -903,7 +903,7 @@ void GameView::NotifySimulationChanged(GameModel * sender) } void GameView::NotifyUserChanged(GameModel * sender) { - if(!sender->GetUser().ID) + if(!sender->GetUser().UserID) { loginButton->SetText("[sign in]"); ((SplitButton*)loginButton)->SetShowSplit(false); @@ -950,19 +950,19 @@ void GameView::NotifySaveChanged(GameModel * sender) else ((SplitButton*)saveSimulationButton)->SetShowSplit(false); reloadButton->Enabled = true; - upVoteButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==0); - if(sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==1) + upVoteButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==0); + if(sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==1) upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 108, 10, 255)); else upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); 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)); else downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); - if (sender->GetUser().ID) + if (sender->GetUser().UserID) { upVoteButton->Appearance.BorderDisabled = upVoteButton->Appearance.BorderInactive; downVoteButton->Appearance.BorderDisabled = downVoteButton->Appearance.BorderInactive; @@ -2080,7 +2080,7 @@ void GameView::UpdateToolStrength() 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."); else if (ctrlBehaviour) ((SplitButton*)saveSimulationButton)->SetToolTips("Overwrite the open simulation on your hard drive.", "Save the simulation to your hard drive."); diff --git a/src/gui/preview/PreviewController.cpp b/src/gui/preview/PreviewController.cpp index 64582c445..7ecc8d7a7 100644 --- a/src/gui/preview/PreviewController.cpp +++ b/src/gui/preview/PreviewController.cpp @@ -24,7 +24,7 @@ PreviewController::PreviewController(int saveID, int saveDate, bool instant, Con previewModel->UpdateSave(saveID, saveDate); - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { previewModel->SetCommentBoxEnabled(true); } @@ -48,7 +48,7 @@ PreviewController::PreviewController(int saveID, bool instant, ControllerCallbac previewModel->UpdateSave(saveID, 0); - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { previewModel->SetCommentBoxEnabled(true); } @@ -105,7 +105,7 @@ void PreviewController::ShowLogin() void PreviewController::NotifyAuthUserChanged(Client * sender) { - previewModel->SetCommentBoxEnabled(sender->GetAuthUser().ID); + previewModel->SetCommentBoxEnabled(sender->GetAuthUser().UserID); } SaveInfo * PreviewController::GetSaveInfo() @@ -136,7 +136,7 @@ void PreviewController::Report(std::string message) void PreviewController::FavouriteSave() { - if(previewModel->GetSaveInfo() && Client::Ref().GetAuthUser().ID) + if(previewModel->GetSaveInfo() && Client::Ref().GetAuthUser().UserID) { try { diff --git a/src/gui/preview/PreviewModel.cpp b/src/gui/preview/PreviewModel.cpp index dc61a6be7..652ee35b0 100644 --- a/src/gui/preview/PreviewModel.cpp +++ b/src/gui/preview/PreviewModel.cpp @@ -83,7 +83,7 @@ void PreviewModel::UpdateSave(int saveID, int saveDate) if (saveDate) urlStream << "&Date=" << saveDate; 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(); if (!GetDoOpen()) @@ -93,7 +93,7 @@ void PreviewModel::UpdateSave(int saveID, int saveDate) urlStream.str(""); urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID << "&Start=" << (commentsPageNumber-1)*20 << "&Count=20"; 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(); } } @@ -146,7 +146,7 @@ void PreviewModel::UpdateComments(int pageNumber) std::stringstream urlStream; urlStream << "http://" << SERVER << "/Browse/Comments.json?ID=" << saveID << "&Start=" << (commentsPageNumber-1)*20 << "&Count=20"; 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(); } diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp index 169da7f2a..c13f50415 100644 --- a/src/gui/preview/PreviewView.cpp +++ b/src/gui/preview/PreviewView.cpp @@ -97,7 +97,7 @@ PreviewView::PreviewView(): favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; favButton->SetIcon(IconFavourite); favButton->SetActionCallback(new FavAction(this)); - favButton->Enabled = Client::Ref().GetAuthUser().ID?true:false; + favButton->Enabled = Client::Ref().GetAuthUser().UserID?true:false; AddComponent(favButton); class ReportPromptCallback: public TextDialogueCallback { @@ -125,7 +125,7 @@ PreviewView::PreviewView(): reportButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; reportButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; reportButton->SetIcon(IconReport); reportButton->SetActionCallback(new ReportAction(this)); - reportButton->Enabled = Client::Ref().GetAuthUser().ID?true:false; + reportButton->Enabled = Client::Ref().GetAuthUser().UserID?true:false; AddComponent(reportButton); 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)); } - if (Client::Ref().GetAuthUser().ID && save->userName == Client::Ref().GetAuthUser().Username) + if (Client::Ref().GetAuthUser().UserID && save->userName == Client::Ref().GetAuthUser().Username) userIsAuthor = true; else userIsAuthor = false; @@ -523,7 +523,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender) favButton->Enabled = true; favButton->SetText("Unfav"); } - else if(Client::Ref().GetAuthUser().ID) + else if(Client::Ref().GetAuthUser().UserID) { favButton->Enabled = true; 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->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; 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)); else if (sender->GetSaveInfo() && sender->GetSaveInfo()->GetUserName() == comments->at(i)->authorName) tempUsername->SetTextColour(ui::Colour(255, 100, 100)); diff --git a/src/gui/profile/ProfileActivity.cpp b/src/gui/profile/ProfileActivity.cpp index 52015eb68..3efd65cdf 100644 --- a/src/gui/profile/ProfileActivity.cpp +++ b/src/gui/profile/ProfileActivity.cpp @@ -21,7 +21,7 @@ ProfileActivity::ProfileActivity(std::string username) : doError(false), 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 diff --git a/src/gui/search/SearchController.cpp b/src/gui/search/SearchController.cpp index 7918ea4de..56282dc7c 100644 --- a/src/gui/search/SearchController.cpp +++ b/src/gui/search/SearchController.cpp @@ -162,7 +162,7 @@ void SearchController::ChangeSort() void SearchController::ShowOwn(bool show) { - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { searchModel->SetShowFavourite(false); searchModel->SetShowOwn(show); @@ -174,7 +174,7 @@ void SearchController::ShowOwn(bool show) void SearchController::ShowFavourite(bool show) { - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) { searchModel->SetShowOwn(false); searchModel->SetShowFavourite(show); @@ -186,7 +186,7 @@ void SearchController::ShowFavourite(bool show) void SearchController::Selected(int saveID, bool selected) { - if(!Client::Ref().GetAuthUser().ID) + if(!Client::Ref().GetAuthUser().UserID) return; if(selected) diff --git a/src/gui/search/SearchModel.cpp b/src/gui/search/SearchModel.cpp index 09b27030c..f135930c8 100644 --- a/src/gui/search/SearchModel.cpp +++ b/src/gui/search/SearchModel.cpp @@ -39,7 +39,7 @@ void * SearchModel::updateSaveListT() std::string category = ""; if(showFavourite) category = "Favourites"; - if(showOwn && Client::Ref().GetAuthUser().ID) + if(showOwn && Client::Ref().GetAuthUser().UserID) category = "by:"+Client::Ref().GetAuthUser().Username; vector * saveList = Client::Ref().SearchSaves((currentPage-1)*20, 20, lastQuery, currentSort=="new"?"date":"votes", category, thResultCount); diff --git a/src/gui/search/SearchView.cpp b/src/gui/search/SearchView.cpp index f49a99877..8ab522f6a 100644 --- a/src/gui/search/SearchView.cpp +++ b/src/gui/search/SearchView.cpp @@ -426,7 +426,7 @@ void SearchView::CheckAccess() favButton->DoAction(); } - if (Client::Ref().GetAuthUser().ID) + if (Client::Ref().GetAuthUser().UserID) { ownButton->Enabled = true; favButton->Enabled = true; @@ -591,7 +591,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender) { nextButton->Enabled = true; previousButton->Enabled = true; - if (Client::Ref().GetAuthUser().ID) + if (Client::Ref().GetAuthUser().UserID) favButton->Enabled = true; } if (!sender->GetSavesLoaded() || favButton->GetToggleState()) @@ -601,7 +601,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender) } else { - if (Client::Ref().GetAuthUser().ID) + if (Client::Ref().GetAuthUser().UserID) ownButton->Enabled = true; sortButton->Enabled = true; } @@ -701,7 +701,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender) saves[i]); saveButton->AddContextMenu(0); saveButton->SetActionCallback(new SaveOpenAction(this)); - if(Client::Ref().GetAuthUser().ID) + if(Client::Ref().GetAuthUser().UserID) saveButton->SetSelectable(true); if (saves[i]->GetUserName() == Client::Ref().GetAuthUser().Username || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator) saveButton->SetShowVotes(true); diff --git a/src/gui/tags/TagsView.cpp b/src/gui/tags/TagsView.cpp index 5c97e4125..79c1b05ec 100644 --- a/src/gui/tags/TagsView.cpp +++ b/src/gui/tags/TagsView.cpp @@ -57,7 +57,7 @@ TagsView::TagsView(): addButton->SetActionCallback(new AddTagAction(this)); AddComponent(addButton); - if (!Client::Ref().GetAuthUser().ID) + if (!Client::Ref().GetAuthUser().UserID) 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"); diff --git a/src/lua/LegacyLuaAPI.cpp b/src/lua/LegacyLuaAPI.cpp index 0131ae54f..f557a0e5b 100644 --- a/src/lua/LegacyLuaAPI.cpp +++ b/src/lua/LegacyLuaAPI.cpp @@ -1463,7 +1463,7 @@ int luatpt_textwidth(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()); return 1; diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index 2364dc4c8..ecf769194 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -128,6 +128,11 @@ #define REPLACE_MODE 0x1 #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 #define SIMULATIONDATA_H diff --git a/src/simulation/elements/ACEL.cpp b/src/simulation/elements/ACEL.cpp index 3dfed18fe..fa554c044 100644 --- a/src/simulation/elements/ACEL.cpp +++ b/src/simulation/elements/ACEL.cpp @@ -71,8 +71,8 @@ int Element_ACEL::update(UPDATE_FUNC_ARGS) continue; if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) { - parts[r>>8].vx *= multiplier; - parts[r>>8].vy *= multiplier; + parts[ID(r)].vx *= multiplier; + parts[ID(r)].vy *= multiplier; parts[i].tmp = 1; } } diff --git a/src/simulation/elements/ACID.cpp b/src/simulation/elements/ACID.cpp index 9abb65719..a81293342 100644 --- a/src/simulation/elements/ACID.cpp +++ b/src/simulation/elements/ACID.cpp @@ -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) { 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[r>>8].life = 4; + parts[ID(r)].life = 4; } 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); 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) { - 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; if(newtemp < 0){ @@ -85,7 +85,7 @@ int Element_ACID::update(UPDATE_FUNC_ARGS) } parts[i].temp += newtemp; parts[i].life--; - sim->kill_part(r>>8); + sim->kill_part(ID(r)); } } else if (parts[i].life<=50) @@ -104,17 +104,17 @@ int Element_ACID::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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) { - parts[r>>8].life++; + parts[ID(r)].life++; parts[i].life--; } else if (temp>0) { - parts[r>>8].life += temp/2; + parts[ID(r)].life += temp/2; parts[i].life -= temp/2; } } diff --git a/src/simulation/elements/AMTR.cpp b/src/simulation/elements/AMTR.cpp index 8589ac419..c7cc1e675 100644 --- a/src/simulation/elements/AMTR.cpp +++ b/src/simulation/elements/AMTR.cpp @@ -66,9 +66,9 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS) return 1; } 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 - sim->kill_part(r>>8); + sim->kill_part(ID(r)); sim->pv[y/CELL][x/CELL] -= 2.0f; } } diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp index a3b354fc3..ac501757b 100644 --- a/src/simulation/elements/ANAR.cpp +++ b/src/simulation/elements/ANAR.cpp @@ -62,7 +62,7 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS) { sim->part_change_type(i,x,y,PT_CFLM); 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; } } diff --git a/src/simulation/elements/ARAY.cpp b/src/simulation/elements/ARAY.cpp index f881b582a..322f6383f 100644 --- a/src/simulation/elements/ARAY.cpp +++ b/src/simulation/elements/ARAY.cpp @@ -56,11 +56,11 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS) int r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF) == PT_SPRK && parts[r>>8].life == 3) + if ((r&0xFF) == PT_SPRK && parts[ID(r)].life == 3) { bool isBlackDeco = false; - int destroy = (parts[r>>8].ctype==PT_PSCN) ? 1 : 0; - int nostop = (parts[r>>8].ctype==PT_INST) ? 1 : 0; + int destroy = (parts[ID(r)].ctype==PT_PSCN) ? 1 : 0; + int nostop = (parts[ID(r)].ctype==PT_INST) ? 1 : 0; int colored = 0, rt; 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]; rt = r & 0xFF; - r = r >> 8; + r = ID(r); if (!rt) { int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp index d5eb2cb46..c54c16e94 100644 --- a/src/simulation/elements/BCLN.cpp +++ b/src/simulation/elements/BCLN.cpp @@ -76,7 +76,7 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS) { parts[i].ctype = rt; if (rt==PT_LIFE || rt==PT_LAVA) - parts[i].tmp = parts[r>>8].ctype; + parts[i].tmp = parts[ID(r)].ctype; } } } diff --git a/src/simulation/elements/BIZR.cpp b/src/simulation/elements/BIZR.cpp index 33fc49047..59f39cdb8 100644 --- a/src/simulation/elements/BIZR.cpp +++ b/src/simulation/elements/BIZR.cpp @@ -62,10 +62,10 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS) continue; if ((r&0xFF)!=PT_BIZR && (r&0xFF)!=PT_BIZRG && (r&0xFF)!=PT_BIZRS) { - tr = (parts[r>>8].dcolour>>16)&0xFF; - tg = (parts[r>>8].dcolour>>8)&0xFF; - tb = (parts[r>>8].dcolour)&0xFF; - ta = (parts[r>>8].dcolour>>24)&0xFF; + tr = (parts[ID(r)].dcolour>>16)&0xFF; + tg = (parts[ID(r)].dcolour>>8)&0xFF; + tb = (parts[ID(r)].dcolour)&0xFF; + ta = (parts[ID(r)].dcolour>>24)&0xFF; mr = (parts[i].dcolour>>16)&0xFF; mg = (parts[i].dcolour>>8)&0xFF; @@ -77,7 +77,7 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS) nb = (tb*BLEND) + (mb*(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; } } } diff --git a/src/simulation/elements/BMTL.cpp b/src/simulation/elements/BMTL.cpp index 11add16bf..68eb05b9a 100644 --- a/src/simulation/elements/BMTL.cpp +++ b/src/simulation/elements/BMTL.cpp @@ -60,8 +60,8 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS) continue; if (((r&0xFF)==PT_METL || (r&0xFF)==PT_IRON) && !(rand()%100)) { - sim->part_change_type(r>>8,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; + sim->part_change_type(ID(r),x+rx,y+ry,PT_BMTL); + parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; } } } diff --git a/src/simulation/elements/BOYL.cpp b/src/simulation/elements/BOYL.cpp index 15ae00dff..6baddcc26 100644 --- a/src/simulation/elements/BOYL.cpp +++ b/src/simulation/elements/BOYL.cpp @@ -71,13 +71,13 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS) if ((r&0xFF)==PT_WATR) { 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) { if (!(rand()%9)) { - sim->kill_part(r>>8); + sim->kill_part(ID(r)); sim->part_change_type(i,x,y,PT_WATR); sim->pv[y/CELL][x/CELL] += 4.0; } diff --git a/src/simulation/elements/BRMT.cpp b/src/simulation/elements/BRMT.cpp index 902703258..d39ca2194 100644 --- a/src/simulation/elements/BRMT.cpp +++ b/src/simulation/elements/BRMT.cpp @@ -64,12 +64,12 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS) { 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 sim->create_part(i, x, y, PT_THRM); - //part_change_type(r>>8,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; + //part_change_type(ID(r),x+rx,y+ry,PT_BMTL); + //parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; } } } diff --git a/src/simulation/elements/BTRY.cpp b/src/simulation/elements/BTRY.cpp index a0928de7c..c25cb2b31 100644 --- a/src/simulation/elements/BTRY.cpp +++ b/src/simulation/elements/BTRY.cpp @@ -56,13 +56,13 @@ int Element_BTRY::update(UPDATE_FUNC_ARGS) if (!r) continue; 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[r>>8].ctype = rt; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; + parts[ID(r)].ctype = rt; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); } } } diff --git a/src/simulation/elements/C5.cpp b/src/simulation/elements/C5.cpp index bff28e603..1945ebff3 100644 --- a/src/simulation/elements/C5.cpp +++ b/src/simulation/elements/C5.cpp @@ -56,12 +56,12 @@ int Element_C5::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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)) { 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; sim->pv[y/CELL][x/CELL] += 1.5; } diff --git a/src/simulation/elements/CAUS.cpp b/src/simulation/elements/CAUS.cpp index 247bcf8c6..1392278fb 100644 --- a/src/simulation/elements/CAUS.cpp +++ b/src/simulation/elements/CAUS.cpp @@ -58,7 +58,7 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS) { 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); } } @@ -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) { // 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; if (newtemp < 0) newtemp = 0; parts[i].temp += newtemp; parts[i].life--; - sim->kill_part(r>>8); + sim->kill_part(ID(r)); } } else if (parts[i].life <= 50) diff --git a/src/simulation/elements/CBNW.cpp b/src/simulation/elements/CBNW.cpp index b768540fc..8f1a449e2 100644 --- a/src/simulation/elements/CBNW.cpp +++ b/src/simulation/elements/CBNW.cpp @@ -99,18 +99,18 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS) { if(!parts[i].tmp) { - if (parts[r>>8].tmp) + if (parts[ID(r)].tmp) { - parts[i].tmp = parts[r>>8].tmp; - if((r>>8)>i) //If the other particle hasn't been life updated + parts[i].tmp = parts[ID(r)].tmp; + if((ID(r))>i) //If the other particle hasn't been life updated parts[i].tmp--; } } - else if(!parts[r>>8].tmp) + else if(!parts[ID(r)].tmp) { - parts[r>>8].tmp = parts[i].tmp; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[r>>8].tmp++; + parts[ID(r)].tmp = parts[i].tmp; + if((ID(r))>i) //If the other particle hasn't been life updated + parts[ID(r)].tmp++; } } 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; } } - else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ - sim->kill_part(r>>8); + else if ((r&0xFF)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){ + sim->kill_part(ID(r)); if(!(rand()%50)){ sim->kill_part(i); return 1; diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp index e86410959..20f4c3bb1 100644 --- a/src/simulation/elements/CLNE.cpp +++ b/src/simulation/elements/CLNE.cpp @@ -67,7 +67,7 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS) { parts[i].ctype = rt; if (rt==PT_LIFE || rt==PT_LAVA) - parts[i].tmp = parts[r>>8].ctype; + parts[i].tmp = parts[ID(r)].ctype; } } } diff --git a/src/simulation/elements/CLST.cpp b/src/simulation/elements/CLST.cpp index 06b9a9582..3bfe30c47 100644 --- a/src/simulation/elements/CLST.cpp +++ b/src/simulation/elements/CLST.cpp @@ -62,13 +62,13 @@ int Element_CLST::update(UPDATE_FUNC_ARGS) if (!(rand()%1500)) { sim->create_part(i, x, y, PT_PSTS); - sim->kill_part(r>>8); + sim->kill_part(ID(r)); } } else if ((r&0xFF)==PT_NITR) { 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) { diff --git a/src/simulation/elements/CO2.cpp b/src/simulation/elements/CO2.cpp index 5790537f8..72cf28f4b 100644 --- a/src/simulation/elements/CO2.cpp +++ b/src/simulation/elements/CO2.cpp @@ -63,7 +63,7 @@ int Element_CO2::update(UPDATE_FUNC_ARGS) continue; } if ((r&0xFF)==PT_FIRE){ - sim->kill_part(r>>8); + sim->kill_part(ID(r)); if(!(rand()%30)){ sim->kill_part(i); 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)) { - 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 { sim->create_part(i, x, y, PT_WATR); diff --git a/src/simulation/elements/CONV.cpp b/src/simulation/elements/CONV.cpp index 712fd0c46..d4b46cb89 100644 --- a/src/simulation/elements/CONV.cpp +++ b/src/simulation/elements/CONV.cpp @@ -67,7 +67,7 @@ int Element_CONV::update(UPDATE_FUNC_ARGS) { parts[i].ctype = r&0xFF; 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; 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); } } } diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp index 42a323feb..f5e2dd7f5 100644 --- a/src/simulation/elements/CRAY.cpp +++ b/src/simulation/elements/CRAY.cpp @@ -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)>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]; if (!r) 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; - bool destroy = parts[r>>8].ctype==PT_PSCN; - bool nostop = parts[r>>8].ctype==PT_INST; - bool createSpark = (parts[r>>8].ctype==PT_INWR); + bool destroy = parts[ID(r)].ctype==PT_PSCN; + bool nostop = parts[ID(r)].ctype==PT_INST; + bool createSpark = (parts[ID(r)].ctype==PT_INWR); int partsRemaining = 255; if (parts[i].tmp) //how far it shoots partsRemaining = parts[i].tmp; @@ -103,19 +103,19 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS) docontinue = 0; } } 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; - 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) colored = 0; - parts[r>>8].life = 4; + parts[ID(r)].life = 4; } else if ((r&0xFF) == PT_CRAY || nostop) { docontinue = 1; } else if(destroy && r && ((r&0xFF) != PT_DMND)) { - sim->kill_part(r>>8); + sim->kill_part(ID(r)); if(!--partsRemaining) docontinue = 0; } diff --git a/src/simulation/elements/DCEL.cpp b/src/simulation/elements/DCEL.cpp index c08b4f1b9..e043ecb2e 100644 --- a/src/simulation/elements/DCEL.cpp +++ b/src/simulation/elements/DCEL.cpp @@ -66,8 +66,8 @@ int Element_DCEL::update(UPDATE_FUNC_ARGS) continue; if (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) { - parts[r>>8].vx *= multiplier; - parts[r>>8].vy *= multiplier; + parts[ID(r)].vx *= multiplier; + parts[ID(r)].vy *= multiplier; parts[i].tmp = 1; } } diff --git a/src/simulation/elements/DEST.cpp b/src/simulation/elements/DEST.cpp index 4329177a5..859d96b8f 100644 --- a/src/simulation/elements/DEST.cpp +++ b/src/simulation/elements/DEST.cpp @@ -64,25 +64,25 @@ int Element_DEST::update(UPDATE_FUNC_ARGS) sim->pv[y/CELL][x/CELL]+=20.0f; if (rand()%2) { - sim->create_part(r>>8, x+rx, y+ry, PT_NEUT); - parts[r>>8].temp = MAX_TEMP; + sim->create_part(ID(r), x+rx, y+ry, PT_NEUT); + parts[ID(r)].temp = MAX_TEMP; sim->pv[y/CELL][x/CELL] += 10.0f; parts[i].life-=4; } } 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)) { - sim->kill_part(r>>8); + sim->kill_part(ID(r)); parts[i].life -= 4*((sim->elements[r&0xFF].Properties&TYPE_SOLID)?3:1); if (parts[i].life<=0) parts[i].life=1; } else if (sim->elements[r&0xFF].HeatConduct) - parts[r>>8].temp = MAX_TEMP; + parts[ID(r)].temp = MAX_TEMP; parts[i].temp=MAX_TEMP; sim->pv[y/CELL][x/CELL]+=80.0f; return 0; diff --git a/src/simulation/elements/DEUT.cpp b/src/simulation/elements/DEUT.cpp index fbdaff568..fea2cd04c 100644 --- a/src/simulation/elements/DEUT.cpp +++ b/src/simulation/elements/DEUT.cpp @@ -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 // 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; - sim->kill_part(r>>8); + parts[i].life += parts[ID(r)].life + 1; + sim->kill_part(ID(r)); } } } @@ -105,17 +105,17 @@ trade: r = pmap[y+ry][x+rx]; if (!r) 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) { - parts[r>>8].life ++; + parts[ID(r)].life ++; parts[i].life --; } else if (temp>0) { - parts[r>>8].life += temp/2; + parts[ID(r)].life += temp/2; parts[i].life -= temp/2; } } diff --git a/src/simulation/elements/DLAY.cpp b/src/simulation/elements/DLAY.cpp index fa73cfb1c..addc47240 100644 --- a/src/simulation/elements/DLAY.cpp +++ b/src/simulation/elements/DLAY.cpp @@ -59,9 +59,9 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { 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; - 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); } @@ -69,18 +69,18 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS) { if (!parts[i].life) { - if (parts[r>>8].life) + if (parts[ID(r)].life) { - parts[i].life = parts[r>>8].life; - if((r>>8)>i) //If the other particle hasn't been life updated + parts[i].life = parts[ID(r)].life; + if((ID(r))>i) //If the other particle hasn't been life updated parts[i].life--; } } - else if (!parts[r>>8].life) + else if (!parts[ID(r)].life) { - parts[r>>8].life = parts[i].life; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[r>>8].life++; + parts[ID(r)].life = parts[i].life; + if((ID(r))>i) //If the other particle hasn't been life updated + parts[ID(r)].life++; } } else if((r&0xFF)==PT_NSCN && oldl==1) diff --git a/src/simulation/elements/DRAY.cpp b/src/simulation/elements/DRAY.cpp index 1bbb91414..344f1cc4c 100644 --- a/src/simulation/elements/DRAY.cpp +++ b/src/simulation/elements/DRAY.cpp @@ -68,12 +68,12 @@ int Element_DRAY::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { 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 - 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; //figure out where the copying will start/end diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp index 27c52c730..ab6a4ca6e 100644 --- a/src/simulation/elements/DSTW.cpp +++ b/src/simulation/elements/DSTW.cpp @@ -61,7 +61,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS) sim->part_change_type(i,x,y,PT_SLTW); // on average, convert 3 DSTW to SLTW before SALT turns into SLTW 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; case PT_SLTW: @@ -85,7 +85,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS) } break; case PT_FIRE: - sim->kill_part(r>>8); + sim->kill_part(ID(r)); if(!(rand()%30)){ sim->kill_part(i); return 1; diff --git a/src/simulation/elements/DTEC.cpp b/src/simulation/elements/DTEC.cpp index 176139960..baaf3d3ba 100644 --- a/src/simulation/elements/DTEC.cpp +++ b/src/simulation/elements/DTEC.cpp @@ -60,13 +60,13 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS) if (!r) continue; 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[r>>8].ctype = rt; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; + parts[ID(r)].ctype = rt; + 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]; if(!r) 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; - 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; - photonWl = parts[r>>8].ctype; + photonWl = parts[ID(r)].ctype; } } if (setFilt) @@ -104,7 +104,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS) ny = y+ry; while ((r&0xFF)==PT_FILT) { - parts[r>>8].ctype = photonWl; + parts[ID(r)].ctype = photonWl; nx += rx; ny += ry; if (nx<0 || ny<0 || nx>=XRES || ny>=YRES) diff --git a/src/simulation/elements/ELEC.cpp b/src/simulation/elements/ELEC.cpp index f9f675930..fd371991e 100644 --- a/src/simulation/elements/ELEC.cpp +++ b/src/simulation/elements/ELEC.cpp @@ -76,36 +76,36 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS) sim->kill_part(i); return 1; case PT_LCRY: - parts[r>>8].tmp2 = 5+rand()%5; + parts[ID(r)].tmp2 = 5+rand()%5; break; case PT_WATR: case PT_DSTW: case PT_SLTW: case PT_CBNW: 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 - 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); return 1; 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; case PT_NEUT: - sim->part_change_type(r>>8, x+rx, y+ry, PT_H2); - parts[r>>8].life = 0; - parts[r>>8].ctype = 0; + sim->part_change_type(ID(r), x+rx, y+ry, PT_H2); + parts[ID(r)].life = 0; + parts[ID(r)].ctype = 0; sim->kill_part(i); break; case PT_DEUT: - if(parts[r>>8].life < 6000) - parts[r>>8].life += 1; - parts[r>>8].temp = 0; + if(parts[ID(r)].life < 6000) + parts[ID(r)].life += 1; + parts[ID(r)].temp = 0; sim->kill_part(i); return 1; case PT_EXOT: - parts[r>>8].tmp2 += 5; - parts[r>>8].life = 1000; + parts[ID(r)].tmp2 += 5; + parts[ID(r)].life = 1000; break; case PT_NONE: //seems to speed up ELEC even if it isn't used break; diff --git a/src/simulation/elements/ETRD.cpp b/src/simulation/elements/ETRD.cpp index 6747f6c49..84b0343bd 100644 --- a/src/simulation/elements/ETRD.cpp +++ b/src/simulation/elements/ETRD.cpp @@ -119,10 +119,10 @@ int Element_ETRD::nearestSparkablePart(Simulation *sim, int targetId) if (sim->InBounds(checkPos.X, checkPos.Y) && checkDistance <= foundDistance) { 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; - foundI = r>>8; + foundI = ID(r); } } } diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp index 462aac2ba..15312b866 100644 --- a/src/simulation/elements/EXOT.cpp +++ b/src/simulation/elements/EXOT.cpp @@ -59,32 +59,32 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) rt = r&0xFF; if (rt == PT_WARP) { - if (parts[r>>8].tmp2>2000 && !(rand()%100)) + if (parts[ID(r)].tmp2>2000 && !(rand()%100)) { parts[i].tmp2 += 100; } } else if (rt == PT_EXOT) { - if (parts[r>>8].ctype == PT_PROT) + if (parts[ID(r)].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; } else if (rt == PT_LAVA) { //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)) { - parts[r>>8].ctype = PT_VIBR; + parts[ID(r)].ctype = PT_VIBR; sim->kill_part(i); return 1; } } //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)) { @@ -138,18 +138,18 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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) { - parts[r>>8].tmp2++; + parts[ID(r)].tmp2++; parts[i].tmp2--; break; } if (tym > 0) { - parts[r>>8].tmp2 += tym/2; + parts[ID(r)].tmp2 += tym/2; parts[i].tmp2 -= tym/2; break; } diff --git a/src/simulation/elements/Element.cpp b/src/simulation/elements/Element.cpp index 6e000fbd7..a243de19f 100644 --- a/src/simulation/elements/Element.cpp +++ b/src/simulation/elements/Element.cpp @@ -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)) { 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)) { sim->part_change_type(i,x,y,PT_WATR); 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)) { 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)) { 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)) sim->part_change_type(i,x,y,PT_WATR); diff --git a/src/simulation/elements/FIRE.cpp b/src/simulation/elements/FIRE.cpp index 2f690e9ed..69053fa1f 100644 --- a/src/simulation/elements/FIRE.cpp +++ b/src/simulation/elements/FIRE.cpp @@ -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 (!(rand()%500)) { - sim->part_change_type(r>>8,x+rx,y+ry,PT_LAVA); - parts[r>>8].ctype = PT_BMTL; - parts[r>>8].temp = 3500.0f; + sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA); + parts[ID(r)].ctype = PT_BMTL; + parts[ID(r)].temp = 3500.0f; sim->pv[(y+ry)/CELL][(x+rx)/CELL] += 50.0f; } else { - sim->part_change_type(r>>8,x+rx,y+ry,PT_LAVA); - parts[r>>8].life = 400; - parts[r>>8].ctype = PT_THRM; - parts[r>>8].temp = 3500.0f; - parts[r>>8].tmp = 20; + sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA); + parts[ID(r)].life = 400; + parts[ID(r)].ctype = PT_THRM; + parts[ID(r)].temp = 3500.0f; + parts[ID(r)].tmp = 20; } continue; } @@ -117,15 +117,15 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS) { if ((t==PT_FIRE || t==PT_PLSM)) { - if (parts[r>>8].life>100 && !(rand()%500)) { - parts[r>>8].life = 99; + if (parts[ID(r)].life>100 && !(rand()%500)) { + parts[ID(r)].life = 99; } } else if (t==PT_LAVA) { if (parts[i].ctype == PT_IRON && !(rand()%500)) { 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) { // 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); if (parts[i].temp >= pres+sim->elements[PT_CRMC].HighTemperature+50.0f) { 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) { - 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); - parts[r>>8].ctype = PT_HEAC; + sim->part_change_type(ID(r), x+rx, y+ry, PT_LAVA); + 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 (t != PT_SPRK || (rt != PT_RBDM && rt != PT_LRBD && 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); - parts[r>>8].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[r>>8].tmp = parts[r>>8].ctype = 0; + sim->part_change_type(ID(r), x+rx, y+ry, PT_FIRE); + parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP); + parts[ID(r)].life = rand()%80+180; + parts[ID(r)].tmp = parts[ID(r)].ctype = 0; if (sim->elements[rt].Explosive) 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 (rt==PT_BRMT) - parts[r>>8].ctype = PT_BMTL; + parts[ID(r)].ctype = PT_BMTL; else if (rt==PT_SAND) - parts[r>>8].ctype = PT_GLAS; + parts[ID(r)].ctype = PT_GLAS; else - parts[r>>8].ctype = rt; - sim->part_change_type(r>>8,x+rx,y+ry,PT_LAVA); - parts[r>>8].life = rand()%120+240; + parts[ID(r)].ctype = rt; + sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA); + parts[ID(r)].life = rand()%120+240; } else { @@ -211,7 +211,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) { } 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) { 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) { - sim->kill_part(r>>8); + sim->kill_part(ID(r)); if (t==PT_FIRE) { sim->kill_part(i); diff --git a/src/simulation/elements/FRAY.cpp b/src/simulation/elements/FRAY.cpp index 7ca4e7fc3..eed6713a5 100644 --- a/src/simulation/elements/FRAY.cpp +++ b/src/simulation/elements/FRAY.cpp @@ -69,8 +69,8 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS) if (!r) r = sim->photons[y+nyi+nyy][x+nxi+nxx]; if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){ - parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f); - parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f); + parts[ID(r)].vx += nxi*((parts[i].temp-273.15)/10.0f); + parts[ID(r)].vy += nyi*((parts[i].temp-273.15)/10.0f); } } } diff --git a/src/simulation/elements/FRZW.cpp b/src/simulation/elements/FRZW.cpp index edc5555f7..fa9a73558 100644 --- a/src/simulation/elements/FRZW.cpp +++ b/src/simulation/elements/FRZW.cpp @@ -57,7 +57,7 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS) continue; 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 ) diff --git a/src/simulation/elements/FRZZ.cpp b/src/simulation/elements/FRZZ.cpp index d060932a9..373ba9f03 100644 --- a/src/simulation/elements/FRZZ.cpp +++ b/src/simulation/elements/FRZZ.cpp @@ -57,8 +57,8 @@ int Element_FRZZ::update(UPDATE_FUNC_ARGS) continue; if ((r&0xFF)==PT_WATR && !(rand()%20)) { - sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW); - parts[r>>8].life = 100; + sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW); + parts[ID(r)].life = 100; sim->kill_part(i); return 1; } diff --git a/src/simulation/elements/GEL.cpp b/src/simulation/elements/GEL.cpp index e8cfd597f..9f3ea1f60 100644 --- a/src/simulation/elements/GEL.cpp +++ b/src/simulation/elements/GEL.cpp @@ -72,14 +72,14 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) if (parts[i].tmp<100 && 500>rand()%absorbChanceDenom) { parts[i].tmp++; - sim->kill_part(r>>8); + sim->kill_part(ID(r)); } break; case PT_PSTE: if (parts[i].tmp<100 && 20>rand()%absorbChanceDenom) { 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; case PT_SLTW: @@ -87,37 +87,37 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) { parts[i].tmp++; if (rand()%4) - sim->kill_part(r>>8); + sim->kill_part(ID(r)); 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; case PT_CBNW: if (parts[i].tmp<100 && 100>rand()%absorbChanceDenom) { 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; case PT_SPNG: // 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 - parts[r>>8].life--; + parts[ID(r)].life--; parts[i].tmp++; } - else if (parts[i].tmp>0 && (parts[r>>8].life+1)0 && (parts[ID(r)].life+1)>8].life++; + parts[ID(r)].life++; parts[i].tmp--; } break; case PT_GEL: - if ((parts[r>>8].tmp+1)>8].tmp++; + parts[ID(r)].tmp++; parts[i].tmp--; } gel = true; @@ -126,8 +126,8 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) break; } float dx, dy; - dx = parts[i].x - parts[r>>8].x; - dy = parts[i].y - parts[r>>8].y; + dx = parts[i].x - parts[ID(r)].x; + dy = parts[i].y - parts[ID(r)].y; //Stickiness 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; if ((sim->elements[rt].Properties&TYPE_PART) || rt==PT_GOO) { - parts[r>>8].vx -= dx; - parts[r>>8].vy -= dy; + parts[ID(r)].vx -= dx; + parts[ID(r)].vy -= dy; } } } diff --git a/src/simulation/elements/GLOW.cpp b/src/simulation/elements/GLOW.cpp index dc6826e1c..a9cdaee57 100644 --- a/src/simulation/elements/GLOW.cpp +++ b/src/simulation/elements/GLOW.cpp @@ -59,8 +59,8 @@ int Element_GLOW::update(UPDATE_FUNC_ARGS) if ((r&0xFF)==PT_WATR && !(rand()%400)) { sim->kill_part(i); - sim->part_change_type(r>>8,x+rx,y+ry,PT_DEUT); - parts[r>>8].life = 10; + sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT); + parts[ID(r)].life = 10; return 1; } } diff --git a/src/simulation/elements/GOLD.cpp b/src/simulation/elements/GOLD.cpp index 8bcb51a8c..466d9e388 100644 --- a/src/simulation/elements/GOLD.cpp +++ b/src/simulation/elements/GOLD.cpp @@ -62,10 +62,10 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS) if ((!rx != !ry) && BOUNDS_CHECK) { r = pmap[y+ry][x+rx]; 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; - sim->part_change_type(r>>8, x+rx, y+ry, PT_IRON); + parts[ID(r)].tmp = 0; + 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) { r = pmap[y+ry][x+rx]; 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); parts[i].life = 4; diff --git a/src/simulation/elements/GPMP.cpp b/src/simulation/elements/GPMP.cpp index 6febb6f0c..f61063c67 100644 --- a/src/simulation/elements/GPMP.cpp +++ b/src/simulation/elements/GPMP.cpp @@ -71,10 +71,10 @@ int Element_GPMP::update(UPDATE_FUNC_ARGS) continue; 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; - else if (parts[r>>8].life==0) - parts[r>>8].life = 10; + else if (parts[ID(r)].life==0) + parts[ID(r)].life = 10; } } } diff --git a/src/simulation/elements/H2.cpp b/src/simulation/elements/H2.cpp index 74930c188..985bf5004 100644 --- a/src/simulation/elements/H2.cpp +++ b/src/simulation/elements/H2.cpp @@ -58,30 +58,30 @@ int Element_H2::update(UPDATE_FUNC_ARGS) 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 { - 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); return 1; } if (sim->pv[y/CELL][x/CELL] > 45.0f) { - if (parts[r>>8].temp > 2273.15) + if (parts[ID(r)].temp > 2273.15) continue; } else { if (rt==PT_FIRE) { - if(parts[r>>8].tmp&0x02) - parts[r>>8].temp=3473.0f; + if(parts[ID(r)].tmp&0x02) + parts[ID(r)].temp=3473.0f; else - parts[r>>8].temp=2473.15f; - parts[r>>8].tmp |= 1; + parts[ID(r)].temp=2473.15f; + parts[ID(r)].tmp |= 1; sim->create_part(i,x,y,PT_FIRE); parts[i].temp+=(rand()%100); parts[i].tmp |= 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); parts[i].temp+=(rand()%100); diff --git a/src/simulation/elements/HEAC.cpp b/src/simulation/elements/HEAC.cpp index 6f4f0e744..634afa9c5 100644 --- a/src/simulation/elements/HEAC.cpp +++ b/src/simulation/elements/HEAC.cpp @@ -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(sim, x, y, x+rrx, y+rry, isInsulator)) { 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++; - tempAgg += parts[r>>8].temp; + tempAgg += parts[ID(r)].temp; } 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++; - 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(sim, x, y, x+rrx, y+rry, isInsulator)) { 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]; - 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; } } } diff --git a/src/simulation/elements/HSWC.cpp b/src/simulation/elements/HSWC.cpp index 00db2c9a8..75fc2061d 100644 --- a/src/simulation/elements/HSWC.cpp +++ b/src/simulation/elements/HSWC.cpp @@ -67,14 +67,14 @@ int Element_HSWC::update(UPDATE_FUNC_ARGS) continue; 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; - else if (parts[r>>8].life==0) - parts[r>>8].life = 10; + else if (parts[ID(r)].life==0) + parts[ID(r)].life = 10; } 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; } } } diff --git a/src/simulation/elements/ICEI.cpp b/src/simulation/elements/ICEI.cpp index 03c16e868..0a3a7f2ee 100644 --- a/src/simulation/elements/ICEI.cpp +++ b/src/simulation/elements/ICEI.cpp @@ -64,14 +64,14 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS) if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200)) { 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; } } else if (((r&0xFF)==PT_FRZZ) && !(rand()%200)) { - sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); - parts[r>>8].ctype = PT_FRZW; + sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI); + parts[ID(r)].ctype = PT_FRZW; } } return 0; diff --git a/src/simulation/elements/IGNT.cpp b/src/simulation/elements/IGNT.cpp index 2c8d4a9ce..d50bd4eac 100644 --- a/src/simulation/elements/IGNT.cpp +++ b/src/simulation/elements/IGNT.cpp @@ -58,7 +58,7 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS) if (!r) continue; 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; } diff --git a/src/simulation/elements/LCRY.cpp b/src/simulation/elements/LCRY.cpp index ef7fa0392..fa7e25ba5 100644 --- a/src/simulation/elements/LCRY.cpp +++ b/src/simulation/elements/LCRY.cpp @@ -92,9 +92,9 @@ int Element_LCRY::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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; diff --git a/src/simulation/elements/LIGH.cpp b/src/simulation/elements/LIGH.cpp index 47e7dbeab..1f4db070e 100644 --- a/src/simulation/elements/LIGH.cpp +++ b/src/simulation/elements/LIGH.cpp @@ -87,13 +87,13 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) continue; rt = r&0xFF; 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->part_change_type(r>>8,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[r>>8].life = rand()%80+180; - parts[r>>8].tmp = parts[r>>8].ctype = 0; + sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE); + parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP); + parts[ID(r)].life = rand()%80+180; + parts[ID(r)].tmp = parts[ID(r)].ctype = 0; if (sim->elements[rt].Explosive) 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_DMND: 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; case PT_DEUT: 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; if (!(rand()%3)) { - sim->part_change_type(r>>8,x+rx,y+ry,PT_NEUT); - parts[r>>8].life = rand()%480+480; - parts[r>>8].vx=rand()%10-5; - parts[r>>8].vy=rand()%10-5; + sim->part_change_type(ID(r),x+rx,y+ry,PT_NEUT); + parts[ID(r)].life = rand()%480+480; + parts[ID(r)].vx=rand()%10-5; + parts[ID(r)].vy=rand()%10-5; } break; case PT_COAL: case PT_BCOL: - if (parts[r>>8].life>100) - parts[r>>8].life = 99; + if (parts[ID(r)].life>100) + parts[ID(r)].life = 99; break; case PT_STKM: if (sim->player.elem!=PT_LIGH) - parts[r>>8].life-=powderful/100; + parts[ID(r)].life-=powderful/100; break; case PT_STKM2: if (sim->player2.elem!=PT_LIGH) - parts[r>>8].life-=powderful/100; + parts[ID(r)].life-=powderful/100; break; case PT_HEAC: - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); - if (parts[r>>8].temp > sim->elements[PT_HEAC].HighTemperature) + parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful/10, MIN_TEMP, MAX_TEMP); + if (parts[ID(r)].temp > sim->elements[PT_HEAC].HighTemperature) { - sim->part_change_type(r>>8, x+rx, y+ry, PT_LAVA); - parts[r>>8].ctype = PT_HEAC; + sim->part_change_type(ID(r), x+rx, y+ry, PT_LAVA); + parts[ID(r)].ctype = PT_HEAC; } break; default: break; } - if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0) - sim->create_part(r>>8,x+rx,y+ry,PT_SPRK); + if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0) + sim->create_part(ID(r),x+rx,y+ry,PT_SPRK); 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) { @@ -260,7 +260,7 @@ int Element_LIGH::contact_part(Simulation * sim, int i, int tp) if (!r) continue; if ((r&0xFF)==tp) - return r>>8; + return ID(r); } 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) { 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; } else return true; diff --git a/src/simulation/elements/LSNS.cpp b/src/simulation/elements/LSNS.cpp index ffd6608fe..907366356 100644 --- a/src/simulation/elements/LSNS.cpp +++ b/src/simulation/elements/LSNS.cpp @@ -60,13 +60,13 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS) if (!r) continue; 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[r>>8].ctype = rt; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; + parts[ID(r)].ctype = rt; + 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]; if(!r) 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; } return 0; diff --git a/src/simulation/elements/MERC.cpp b/src/simulation/elements/MERC.cpp index 6dff7a5da..51af9effc 100644 --- a/src/simulation/elements/MERC.cpp +++ b/src/simulation/elements/MERC.cpp @@ -73,10 +73,10 @@ int Element_MERC::update(UPDATE_FUNC_ARGS) continue; 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; - sim->kill_part(r>>8); + parts[i].tmp += parts[ID(r)].tmp + 1; + sim->kill_part(ID(r)); } } } @@ -108,17 +108,17 @@ int Element_MERC::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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) { - parts[r>>8].tmp ++; + parts[ID(r)].tmp ++; parts[i].tmp --; } else if (temp>0) { - parts[r>>8].tmp += temp/2; + parts[ID(r)].tmp += temp/2; parts[i].tmp -= temp/2; } } diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp index 81bb421c2..be205fead 100644 --- a/src/simulation/elements/NEUT.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -59,7 +59,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS) { case PT_WATR: 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_SNOW: parts[i].vx *= 0.995; @@ -70,18 +70,18 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS) { if (!(rand()%3)) { - sim->create_part(r>>8, x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN); - parts[r>>8].temp = MAX_TEMP; - if (parts[r>>8].type==PT_LAVA) { - parts[r>>8].tmp = 100; - parts[r>>8].ctype = PT_PLUT; + sim->create_part(ID(r), x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN); + parts[ID(r)].temp = MAX_TEMP; + if (parts[ID(r)].type==PT_LAVA) { + parts[ID(r)].tmp = 100; + parts[ID(r)].ctype = PT_PLUT; } } else { - sim->create_part(r>>8, x+rx, y+ry, PT_NEUT); - parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; - parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; + sim->create_part(ID(r), x+rx, y+ry, PT_NEUT); + parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx; + 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 Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); @@ -89,21 +89,21 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS) break; #ifdef SDEUT 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); - sim->kill_part(r>>8); + 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(ID(r)); } break; #else case PT_DEUT: if ((pressureFactor+1)>(rand()%1000)) { - create_part(r>>8, x+rx, y+ry, PT_NEUT); - parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; - parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; - parts[r>>8].life --; - parts[r>>8].temp = restrict_flt(parts[r>>8].temp + parts[r>>8].life*17.0f, MIN_TEMP, MAX_TEMP); + create_part(ID(r), x+rx, y+ry, PT_NEUT); + parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx; + parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy; + parts[ID(r)].life --; + 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; } @@ -111,51 +111,51 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS) #endif case PT_GUNP: 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; case PT_DYST: 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; 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; case PT_PLEX: 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; case PT_NITR: 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; case PT_PLNT: 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; case PT_DESL: case PT_OIL: 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; case PT_COAL: 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; case PT_BCOL: 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; case PT_DUST: 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; case PT_FWRK: if (!(rand()%20)) - parts[r>>8].ctype = PT_DUST; + parts[ID(r)].ctype = PT_DUST; break; case PT_ACID: 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; case PT_TTAN: if (!(rand()%20)) @@ -166,13 +166,13 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS) break; case PT_EXOT: if (!(rand()%20)) - parts[r>>8].life = 1500; + parts[ID(r)].life = 1500; break; case PT_RFRG: 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 - sim->create_part(r>>8, x+rx, y+ry, PT_CAUS); + sim->create_part(ID(r), x+rx, y+ry, PT_CAUS); break; default: break; diff --git a/src/simulation/elements/O2.cpp b/src/simulation/elements/O2.cpp index 57c7bd7e3..0bf08d369 100644 --- a/src/simulation/elements/O2.cpp +++ b/src/simulation/elements/O2.cpp @@ -58,16 +58,16 @@ int Element_O2::update(UPDATE_FUNC_ARGS) if ((r&0xFF)==PT_FIRE) { - parts[r>>8].temp+=(rand()%100); - if(parts[r>>8].tmp&0x01) - parts[r>>8].temp=3473; - parts[r>>8].tmp |= 2; + parts[ID(r)].temp+=(rand()%100); + if(parts[ID(r)].tmp&0x01) + parts[ID(r)].temp=3473; + parts[ID(r)].tmp |= 2; sim->create_part(i,x,y,PT_FIRE); parts[i].temp+=(rand()%100); 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); parts[i].temp+=(rand()%100); diff --git a/src/simulation/elements/PBCN.cpp b/src/simulation/elements/PBCN.cpp index 34e9ee350..28afceeb7 100644 --- a/src/simulation/elements/PBCN.cpp +++ b/src/simulation/elements/PBCN.cpp @@ -82,7 +82,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS) { parts[i].ctype = rt; 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) @@ -101,10 +101,10 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS) continue; 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; - else if (parts[r>>8].life==0) - parts[r>>8].life = 10; + else if (parts[ID(r)].life==0) + parts[ID(r)].life = 10; } } if (parts[i].ctype>0 && parts[i].ctypeelements[parts[i].ctype].Enabled) diff --git a/src/simulation/elements/PCLN.cpp b/src/simulation/elements/PCLN.cpp index 5272d3519..393d5f9f2 100644 --- a/src/simulation/elements/PCLN.cpp +++ b/src/simulation/elements/PCLN.cpp @@ -60,19 +60,19 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) continue; 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; - else if (parts[r>>8].ctype==PT_NSCN) + else if (parts[ID(r)].ctype==PT_NSCN) parts[i].life = 9; } } 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; - 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; } } @@ -95,7 +95,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) { parts[i].ctype = rt; 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].ctypeelements[parts[i].ctype].Enabled && parts[i].life==10) diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index c559a7f86..b65605d09 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -68,14 +68,14 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) { parts[i].vx *= 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; if ((r&0xFF) == PT_ISOZ) rr = (rand()%128+128)/127.0f; else rr = (rand()%228+128)/127.0f; - parts[r>>8].vx = rr*cosf(rrr); - parts[r>>8].vy = rr*sinf(rrr); + parts[ID(r)].vx = rr*cosf(rrr); + parts[ID(r)].vy = rr*sinf(rrr); 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].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].vy += ((float)(rand()%1000-500))/1000.0f; diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp index 56e0a13cd..eba1f880e 100644 --- a/src/simulation/elements/PIPE.cpp +++ b/src/simulation/elements/PIPE.cpp @@ -104,9 +104,9 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) if ((r&0xFF) == PT_BRCK) { if (parts[i].tmp & PPIP_TMPFLAG_PAUSED) - parts[r>>8].tmp = 0; + parts[ID(r)].tmp = 0; 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]; if (!r) 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[r>>8].life = 6; + parts[ID(r)].ctype = (((parts[i].ctype)%3)+2);//reverse + parts[ID(r)].life = 6; if ( parts[i].tmp&0x100)//is a single pixel pipe { - parts[r>>8].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 |= 0x200;//will transfer to a single pixel pipe + parts[ID(r)].tmp |= count<<10;//coords of where it came from parts[i].tmp |= ((7-count)<<14); parts[i].tmp |= 0x2000; } 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 ++; - lastneighbor = r>>8; + lastneighbor = ID(r); } 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))) { if ((r&0xFF)==PT_SOAP) - Element_SOAP::detach(sim, r>>8); - transfer_part_to_pipe(parts+(r>>8), parts+i); - sim->kill_part(r>>8); + Element_SOAP::detach(sim, ID(r)); + transfer_part_to_pipe(parts+(ID(r)), parts+i); + 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 - 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]; if (!r) 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)); - if (r>>8 > original) - sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed + transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r))); + if (ID(r) > original) + sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed 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 { - int portaltmp = sim->parts[r>>8].tmp; + int portaltmp = sim->parts[ID(r)].tmp; if (portaltmp >= CHANNELS) portaltmp = CHANNELS-1; 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); 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)); - if (r>>8 > original) - sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed + transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r))); + if (ID(r) > original) + sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed 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 { - int portaltmp = sim->parts[r>>8].tmp; + int portaltmp = sim->parts[ID(r)].tmp; if (portaltmp >= CHANNELS) portaltmp = CHANNELS-1; else if (portaltmp < 0) diff --git a/src/simulation/elements/PLNT.cpp b/src/simulation/elements/PLNT.cpp index 704e4e4c7..0b3eee34f 100644 --- a/src/simulation/elements/PLNT.cpp +++ b/src/simulation/elements/PLNT.cpp @@ -62,7 +62,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS) case PT_WATR: 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; parts[np].life = 0; } @@ -78,7 +78,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS) case PT_CO2: if (!(rand()%50)) { - sim->kill_part(r>>8); + sim->kill_part(ID(r)); parts[i].life = rand()%60 + 60; } break; diff --git a/src/simulation/elements/POLO.cpp b/src/simulation/elements/POLO.cpp index 321c63571..368a29326 100644 --- a/src/simulation/elements/POLO.cpp +++ b/src/simulation/elements/POLO.cpp @@ -73,15 +73,15 @@ int Element_POLO::update(UPDATE_FUNC_ARGS) int s = sim->create_part(-3, x, y, PT_NEUT); 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].tmp++; - parts[r>>8].temp = parts[i].temp; + parts[ID(r)].temp = parts[i].temp; parts[s].temp = parts[i].temp; - parts[s].vx = parts[r>>8].vx; - parts[s].vy = parts[r>>8].vy; + parts[s].vx = parts[ID(r)].vx; + 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; return 1; } - if (parts[r>>8].type == PT_PROT) + if (parts[ID(r)].type == PT_PROT) { parts[i].tmp2++; - sim->kill_part(r>>8); + sim->kill_part(ID(r)); } if (parts[i].temp < 388.15f) { diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp index 282f59b3c..0d6437a74 100644 --- a/src/simulation/elements/PRTI.cpp +++ b/src/simulation/elements/PRTI.cpp @@ -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() if ((r&0xFF) == PT_SOAP) - Element_SOAP::detach(sim, r>>8); + Element_SOAP::detach(sim, ID(r)); for (int nnx=0; nnx<80; nnx++) if (!sim->portalp[parts[i].tmp][count][nnx].type) { 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 - 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; } } 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) - 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 - sim->kill_part(r>>8); + sim->kill_part(ID(r)); fe = 1; break; } diff --git a/src/simulation/elements/PSNS.cpp b/src/simulation/elements/PSNS.cpp index 06f9d9d3d..e4ce0ee1d 100644 --- a/src/simulation/elements/PSNS.cpp +++ b/src/simulation/elements/PSNS.cpp @@ -59,13 +59,13 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS) if (!r) continue; 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[r>>8].ctype = rt; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; + parts[ID(r)].ctype = rt; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); } } } diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index e638487d1..e27b3444b 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/src/simulation/elements/PSTN.cpp @@ -88,8 +88,8 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) { - if(parts[r>>8].ctype == PT_PSCN) + if ((r&0xFF)==PT_SPRK && parts[ID(r)].life==3) { + if(parts[ID(r)].ctype == PT_PSCN) state = PISTON_EXTEND; else state = PISTON_RETRACT; @@ -121,7 +121,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) r = pmap[y+nyy][x+nxx]; if((r&0xFF)==PT_PSTN) { - if(parts[r>>8].life) + if(parts[ID(r)].life) armCount++; else if (armCount) { @@ -132,7 +132,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) } 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) @@ -214,7 +214,7 @@ Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX, else { if (currentPos - spaces < maxSize && (!retract || ((r&0xFF) == PT_FRME && posX == stackX && posY == stackY))) - tempParts[currentPos++] = r>>8; + tempParts[currentPos++] = ID(r); else return StackData(currentPos - spaces, spaces); } @@ -293,7 +293,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct break; } else { foundParts = true; - tempParts[currentPos++] = r>>8; + tempParts[currentPos++] = ID(r); } } if(foundParts) { diff --git a/src/simulation/elements/PUMP.cpp b/src/simulation/elements/PUMP.cpp index 7a8cbba4f..477290428 100644 --- a/src/simulation/elements/PUMP.cpp +++ b/src/simulation/elements/PUMP.cpp @@ -76,10 +76,10 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS) continue; 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; - else if (parts[r>>8].life==0) - parts[r>>8].life = 10; + else if (parts[ID(r)].life==0) + parts[ID(r)].life = 10; } } } diff --git a/src/simulation/elements/PVOD.cpp b/src/simulation/elements/PVOD.cpp index d13746e83..d0262317a 100644 --- a/src/simulation/elements/PVOD.cpp +++ b/src/simulation/elements/PVOD.cpp @@ -60,19 +60,19 @@ int Element_PVOD::update(UPDATE_FUNC_ARGS) continue; 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; - else if (parts[r>>8].ctype==PT_NSCN) + else if (parts[ID(r)].ctype==PT_NSCN) parts[i].life = 9; } } 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; - 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; } } diff --git a/src/simulation/elements/QRTZ.cpp b/src/simulation/elements/QRTZ.cpp index 7d44294c5..eeed7ae76 100644 --- a/src/simulation/elements/QRTZ.cpp +++ b/src/simulation/elements/QRTZ.cpp @@ -72,7 +72,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS) continue; else if ((r&0xFF)==PT_SLTW && !(rand()%500)) { - sim->kill_part(r>>8); + sim->kill_part(ID(r)); parts[i].tmp++; } } @@ -122,18 +122,18 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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) { - parts[r>>8].tmp++; + parts[ID(r)].tmp++; parts[i].tmp--; break; } if (tmp>0) { - parts[r>>8].tmp += tmp/2; + parts[ID(r)].tmp += tmp/2; parts[i].tmp -= tmp/2; break; } diff --git a/src/simulation/elements/RIME.cpp b/src/simulation/elements/RIME.cpp index a0ebbc822..bccee9004 100644 --- a/src/simulation/elements/RIME.cpp +++ b/src/simulation/elements/RIME.cpp @@ -60,10 +60,10 @@ int Element_RIME::update(UPDATE_FUNC_ARGS) sim->part_change_type(i,x,y,PT_FOG); 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); - parts[i].life = parts[r>>8].life; + parts[i].life = parts[ID(r)].life; } } return 0; diff --git a/src/simulation/elements/RPEL.cpp b/src/simulation/elements/RPEL.cpp index 001939f78..924d6c6d5 100644 --- a/src/simulation/elements/RPEL.cpp +++ b/src/simulation/elements/RPEL.cpp @@ -59,9 +59,9 @@ int Element_RPEL::update(UPDATE_FUNC_ARGS) r = sim->photons[y+ry][x+rx]; if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)) { - if (!parts[i].ctype || parts[i].ctype == parts[r>>8].type) { - parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); - parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); + if (!parts[i].ctype || parts[i].ctype == parts[ID(r)].type) { + parts[ID(r)].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); + parts[ID(r)].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); } } } diff --git a/src/simulation/elements/SHLD3.cpp b/src/simulation/elements/SHLD3.cpp index 047d04315..61a264829 100644 --- a/src/simulation/elements/SHLD3.cpp +++ b/src/simulation/elements/SHLD3.cpp @@ -66,8 +66,8 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS) } if ((r&0xFF)==PT_SHLD1 && parts[i].life>3) { - sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD2); - parts[r>>8].life=7; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD2); + parts[ID(r)].life=7; } else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) { diff --git a/src/simulation/elements/SHLD4.cpp b/src/simulation/elements/SHLD4.cpp index 5e0c5da38..98e0e4d4a 100644 --- a/src/simulation/elements/SHLD4.cpp +++ b/src/simulation/elements/SHLD4.cpp @@ -67,8 +67,8 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS) } if ((r&0xFF)==PT_SHLD2 && parts[i].life>3) { - sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD3); - parts[r>>8].life = 7; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD3); + parts[ID(r)].life = 7; } else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) for ( nnx=-1; nnx<2; nnx++) diff --git a/src/simulation/elements/SING.cpp b/src/simulation/elements/SING.cpp index 1a42c7d55..8d78826dd 100644 --- a/src/simulation/elements/SING.cpp +++ b/src/simulation/elements/SING.cpp @@ -113,20 +113,20 @@ int Element_SING::update(UPDATE_FUNC_ARGS) continue; 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; - parts[i].life += parts[r>>8].life; + parts[i].life += parts[ID(r)].life; } else { 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; - 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; } continue; @@ -134,8 +134,8 @@ int Element_SING::update(UPDATE_FUNC_ARGS) parts[i].life += 3; parts[i].tmp++; } - parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); - sim->kill_part(r>>8); + parts[i].temp = restrict_flt(parts[ID(r)].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); + sim->kill_part(ID(r)); } } return 0; diff --git a/src/simulation/elements/SLTW.cpp b/src/simulation/elements/SLTW.cpp index f3db0e56e..a0363e751 100644 --- a/src/simulation/elements/SLTW.cpp +++ b/src/simulation/elements/SLTW.cpp @@ -57,11 +57,11 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS) { case PT_SALT: 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; case PT_PLNT: if (!(rand()%40)) - sim->kill_part(r>>8); + sim->kill_part(ID(r)); break; case PT_RBDM: case PT_LRBD: @@ -73,9 +73,9 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS) } break; 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)){ sim->kill_part(i); return 1; diff --git a/src/simulation/elements/SNOW.cpp b/src/simulation/elements/SNOW.cpp index 0f5a737f2..62e7a7a61 100644 --- a/src/simulation/elements/SNOW.cpp +++ b/src/simulation/elements/SNOW.cpp @@ -63,7 +63,7 @@ int Element_SNOW::update(UPDATE_FUNC_ARGS) if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && !(rand()%333)) { 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; diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index d3ecdb091..57e05f95e 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -146,8 +146,8 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((parts[r>>8].type == PT_SOAP) && (parts[r>>8].ctype&1) && !(parts[r>>8].ctype&4)) - Element_SOAP::attach(parts, i, r>>8); + if ((parts[ID(r)].type == PT_SOAP) && (parts[ID(r)].ctype&1) && !(parts[ID(r)].ctype&4)) + Element_SOAP::attach(parts, i, ID(r)); } } else @@ -172,25 +172,25 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) } if ((r&0xFF) == PT_SOAP) { - if (parts[r>>8].ctype == 1) + if (parts[ID(r)].ctype == 1) { int buf = parts[i].tmp; - parts[i].tmp = r>>8; + parts[i].tmp = ID(r); if (parts[buf].type == PT_SOAP) - parts[buf].tmp2 = r>>8; - parts[r>>8].tmp2 = i; - parts[r>>8].tmp = buf; - parts[r>>8].ctype = 7; + parts[buf].tmp2 = ID(r); + parts[ID(r)].tmp2 = i; + parts[ID(r)].tmp = buf; + 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) - parts[parts[i].tmp].tmp2 = parts[r>>8].tmp2; - if (parts[parts[r>>8].tmp2].type == PT_SOAP) - parts[parts[r>>8].tmp2].tmp = parts[i].tmp; - parts[r>>8].tmp2 = i; - parts[i].tmp = r>>8; + parts[parts[i].tmp].tmp2 = parts[ID(r)].tmp2; + if (parts[parts[ID(r)].tmp2].type == PT_SOAP) + parts[parts[ID(r)].tmp2].tmp = parts[i].tmp; + parts[ID(r)].tmp2 = i; + parts[i].tmp = ID(r); } } } @@ -240,10 +240,10 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) if ((r&0xFF) == PT_OIL) { float ax, ay; - ax = (parts[i].vx*0.5f + parts[r>>8].vx)/2; - ay = ((parts[i].vy-0.1f)*0.5f + parts[r>>8].vy)/2; - parts[i].vx = parts[r>>8].vx = ax; - parts[i].vy = parts[r>>8].vy = ay; + ax = (parts[i].vx*0.5f + parts[ID(r)].vx)/2; + ay = ((parts[i].vy-0.1f)*0.5f + parts[ID(r)].vy)/2; + parts[i].vx = parts[ID(r)].vx = ax; + parts[i].vy = parts[ID(r)].vy = ay; } } } @@ -256,15 +256,15 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) continue; if ((r&0xFF)!=PT_SOAP) { - tr = (parts[r>>8].dcolour>>16)&0xFF; - tg = (parts[r>>8].dcolour>>8)&0xFF; - tb = (parts[r>>8].dcolour)&0xFF; - ta = (parts[r>>8].dcolour>>24)&0xFF; + tr = (parts[ID(r)].dcolour>>16)&0xFF; + tg = (parts[ID(r)].dcolour>>8)&0xFF; + tb = (parts[ID(r)].dcolour)&0xFF; + ta = (parts[ID(r)].dcolour>>24)&0xFF; nr = (tr*BLEND); ng = (tg*BLEND); nb = (tb*BLEND); na = (ta*BLEND); - parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; + parts[ID(r)].dcolour = nr<<16 | ng<<8 | nb | na<<24; } } diff --git a/src/simulation/elements/SPNG.cpp b/src/simulation/elements/SPNG.cpp index c9a0c6c1b..a0fdfc383 100644 --- a/src/simulation/elements/SPNG.cpp +++ b/src/simulation/elements/SPNG.cpp @@ -66,7 +66,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) if (parts[i].liferand()%absorbChanceDenom) { parts[i].life++; - sim->kill_part(r>>8); + sim->kill_part(ID(r)); } break; case PT_SLTW: @@ -74,23 +74,23 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) { parts[i].life++; if (rand()%4) - sim->kill_part(r>>8); + sim->kill_part(ID(r)); 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; case PT_CBNW: if (parts[i].liferand()%absorbChanceDenom) { 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; case PT_PSTE: if (parts[i].liferand()%absorbChanceDenom) { 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; default: @@ -119,18 +119,18 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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) { - parts[r>>8].life ++; + parts[ID(r)].life ++; parts[i].life --; trade = 9; } else if (tmp>0) { - parts[r>>8].life += tmp/2; + parts[ID(r)].life += tmp/2; parts[i].life -= tmp/2; trade = 9; } @@ -150,10 +150,10 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) if ((r&0xFF)==PT_FIRE) { tmp++; - if (parts[r>>8].life>60) - parts[r>>8].life -= parts[r>>8].life/60; - else if (parts[r>>8].life>2) - parts[r>>8].life--; + if (parts[ID(r)].life>60) + parts[ID(r)].life -= parts[ID(r)].life/60; + else if (parts[ID(r)].life>2) + parts[ID(r)].life--; } } } diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index 90c2cae17..7652ab492 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -152,9 +152,9 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) { int rnd = rand()%100; 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) - 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; @@ -174,7 +174,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) continue; receiver = r&0xFF; 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 //sender is the element the SPRK is on //First, some checks usually for (de)activation of elements @@ -183,47 +183,47 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) case PT_SWCH: if (pavg!=PT_INSL && parts[i].life<4) { - if(sender==PT_PSCN && parts[r>>8].life<10) { - parts[r>>8].life = 10; + if(sender==PT_PSCN && parts[ID(r)].life<10) { + parts[ID(r)].life = 10; } else if (sender==PT_NSCN) { - parts[r>>8].ctype = PT_NONE; - parts[r>>8].life = 9; + parts[ID(r)].ctype = PT_NONE; + parts[ID(r)].life = 9; } } break; case PT_SPRK: 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) { - sim->part_change_type(r>>8,x+rx,y+ry,PT_SWCH); - parts[r>>8].ctype = PT_NONE; - parts[r>>8].life = 9; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SWCH); + parts[ID(r)].ctype = PT_NONE; + 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) { - parts[r>>8].temp = 473.0f; + parts[ID(r)].temp = 473.0f; } } continue; 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 (sender==PT_PSCN) parts[r>>8].life = 10; - else if (sender==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9; + if (sender==PT_PSCN) parts[ID(r)].life = 10; + else if (sender==PT_NSCN && parts[ID(r)].life>=10) parts[ID(r)].life = 9; } continue; case PT_LCRY: 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; - else if (sender==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1; + if (sender==PT_PSCN && parts[ID(r)].tmp == 0) parts[ID(r)].tmp = 2; + else if (sender==PT_NSCN && parts[ID(r)].tmp == 3) parts[ID(r)].tmp = 1; } continue; case PT_PPIP: @@ -236,19 +236,19 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) case PT_NTCT: case PT_PTCT: case PT_INWR: 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) continue; } break; 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_decor += 3; if (sim->emp_decor > 40) sim->emp_decor = 40; - parts[r>>8].life = 220; + parts[ID(r)].life = 220; } continue; } @@ -292,15 +292,15 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) switch (receiver) { 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; continue; 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; continue; 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; continue; case PT_INWR: @@ -325,35 +325,35 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) conduct: //Yay, passed normal conduction rules, check a few last things and change receiver to spark 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); - if (receiver==PT_WATR) parts[r>>8].life = 6; - else parts[r>>8].life = 5; - parts[r>>8].ctype = receiver; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); + if (receiver==PT_WATR) parts[ID(r)].life = 6; + else parts[ID(r)].life = 5; + parts[ID(r)].ctype = receiver; } } 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 } } - else if (parts[r>>8].life==0 && parts[i].life<4) { - parts[r>>8].life = 4; - parts[r>>8].ctype = receiver; - sim->part_change_type(r>>8,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)) - parts[r>>8].temp = parts[r>>8].temp+10.0f; + else if (parts[ID(r)].life==0 && parts[i].life<4) { + parts[ID(r)].life = 4; + parts[ID(r)].ctype = receiver; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); + 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[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); parts[i].ctype = PT_NONE; parts[i].life = 20; - parts[r>>8].life = 4; - parts[r>>8].ctype = receiver; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; + parts[ID(r)].ctype = receiver; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); } } return 0; diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 0c16109ee..183128b1f 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -375,14 +375,14 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { parts[i].life += 5; else parts[i].life = 100; - sim->kill_part(r>>8); + sim->kill_part(ID(r)); } if ((r&0xFF) == PT_NEUT) { if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2; 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) 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; } - 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; 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) { 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); - if (sim->parts[r>>8].tmp>=CHANNELS) sim->parts[r>>8].tmp = CHANNELS-1; - else if (sim->parts[r>>8].tmp<0) sim->parts[r>>8].tmp = 0; + sim->parts[ID(r)].tmp = (int)((sim->parts[ID(r)].temp-73.15f)/100+1); + if (sim->parts[ID(r)].tmp>=CHANNELS) sim->parts[ID(r)].tmp = CHANNELS-1; + else if (sim->parts[ID(r)].tmp<0) sim->parts[ID(r)].tmp = 0; 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); //stop new STKM/fighters being created to replace the ones in the portal: 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++; break; } @@ -625,11 +625,11 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int { 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); } - 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); } diff --git a/src/simulation/elements/STOR.cpp b/src/simulation/elements/STOR.cpp index 08e025273..dbd98e541 100644 --- a/src/simulation/elements/STOR.cpp +++ b/src/simulation/elements/STOR.cpp @@ -58,20 +58,20 @@ int Element_STOR::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) + if ((ID(r))>=NPART || !r) 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 ((r&0xFF) == PT_SOAP) - Element_SOAP::detach(sim, r>>8); - parts[i].tmp = parts[r>>8].type; - parts[i].temp = parts[r>>8].temp; - parts[i].tmp2 = parts[r>>8].life; - parts[i].pavg[0] = parts[r>>8].tmp; - parts[i].pavg[1] = parts[r>>8].ctype; - sim->kill_part(r>>8); + Element_SOAP::detach(sim, ID(r)); + parts[i].tmp = parts[ID(r)].type; + parts[i].temp = parts[ID(r)].temp; + parts[i].tmp2 = parts[ID(r)].life; + parts[i].pavg[0] = parts[ID(r)].tmp; + parts[i].pavg[1] = parts[ID(r)].ctype; + 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(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) diff --git a/src/simulation/elements/SWCH.cpp b/src/simulation/elements/SWCH.cpp index b023207f2..ef69bc233 100644 --- a/src/simulation/elements/SWCH.cpp +++ b/src/simulation/elements/SWCH.cpp @@ -63,19 +63,19 @@ int Element_SWCH::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) 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; 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; - 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 - 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); parts[i].ctype = PT_SWCH; parts[i].life = 4; diff --git a/src/simulation/elements/THDR.cpp b/src/simulation/elements/THDR.cpp index 453d0c63c..a9bd61f46 100644 --- a/src/simulation/elements/THDR.cpp +++ b/src/simulation/elements/THDR.cpp @@ -58,11 +58,11 @@ int Element_THDR::update(UPDATE_FUNC_ARGS) if (!r) continue; 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; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; + parts[ID(r)].ctype = parts[ID(r)].type; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; kill=true; } else if (rt!=PT_CLNE&&rt!=PT_THDR&&rt!=PT_SPRK&&rt!=PT_DMND&&rt!=PT_FIRE) diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp index 74b7ee1c3..c25453bcd 100644 --- a/src/simulation/elements/TRON.cpp +++ b/src/simulation/elements/TRON.cpp @@ -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) 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; - 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 false; } diff --git a/src/simulation/elements/TSNS.cpp b/src/simulation/elements/TSNS.cpp index ddc158820..1d4792c9a 100644 --- a/src/simulation/elements/TSNS.cpp +++ b/src/simulation/elements/TSNS.cpp @@ -61,13 +61,13 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS) if (!r) continue; 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[r>>8].ctype = rt; - sim->part_change_type(r>>8, x+rx, y+ry, PT_SPRK); + parts[ID(r)].life = 4; + parts[ID(r)].ctype = rt; + 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]; if (!r) 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; if (parts[i].tmp == 1 && (r&0xFF) != PT_TSNS && (r&0xFF) != PT_FILT) { setFilt = true; - photonWl = parts[r>>8].temp; + photonWl = parts[ID(r)].temp; } } if (setFilt) @@ -105,7 +105,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS) ny = y + ry; while ((r & 0xFF) == PT_FILT) { - parts[r>>8].ctype = 0x10000000 + photonWl; + parts[ID(r)].ctype = 0x10000000 + photonWl; nx += rx; ny += ry; if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES) diff --git a/src/simulation/elements/VIBR.cpp b/src/simulation/elements/VIBR.cpp index 67d01d76f..467671935 100644 --- a/src/simulation/elements/VIBR.cpp +++ b/src/simulation/elements/VIBR.cpp @@ -87,11 +87,11 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { ry = (rndstore>>2)%3-1; rndstore = rndstore >> 4; 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[r>>8].ctype = r&0xFF; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; + parts[ID(r)].ctype = r&0xFF; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); } } //Release all heat @@ -102,9 +102,9 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { if(BOUNDS_CHECK) { 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; } } @@ -154,11 +154,11 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { //Makes EXOT around it get tmp to start exploding too if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR)) { - if (!parts[r>>8].life) - parts[r>>8].tmp += 45; + if (!parts[ID(r)].life) + parts[ID(r)].tmp += 45; 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; } } @@ -197,10 +197,10 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if ((r&0xFF) != PT_VIBR && (r&0xFF) != PT_BVBR) 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; - parts[r>>8].tmp += transfer/2; + transfer = parts[i].tmp - parts[ID(r)].tmp; + parts[ID(r)].tmp += transfer/2; parts[i].tmp -= transfer/2; break; } diff --git a/src/simulation/elements/VIRS.cpp b/src/simulation/elements/VIRS.cpp index 1d3ce8c03..fa23c2ce0 100644 --- a/src/simulation/elements/VIRS.cpp +++ b/src/simulation/elements/VIRS.cpp @@ -86,9 +86,9 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS) continue; //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; } //soap cures virus @@ -96,7 +96,7 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS) { parts[i].pavg[0] += 10; if (!(rndstore & 0x3)) - sim->kill_part(r>>8); + sim->kill_part(ID(r)); return 0; } else if ((r&0xFF) == PT_PLSM) @@ -112,18 +112,18 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS) { if (!(rndstore & 0x7)) { - parts[r>>8].tmp2 = (r&0xFF); - parts[r>>8].pavg[0] = 0; + parts[ID(r)].tmp2 = (r&0xFF); + parts[ID(r)].pavg[0] = 0; 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 - parts[r>>8].pavg[1] = 0; - if (parts[r>>8].temp < 305.0f) - sim->part_change_type(r>>8, x+rx, y+ry, PT_VRSS); - else if (parts[r>>8].temp > 673.0f) - sim->part_change_type(r>>8, x+rx, y+ry, PT_VRSG); + parts[ID(r)].pavg[1] = 0; + if (parts[ID(r)].temp < 305.0f) + sim->part_change_type(ID(r), x+rx, y+ry, PT_VRSS); + else if (parts[ID(r)].temp > 673.0f) + sim->part_change_type(ID(r), x+rx, y+ry, PT_VRSG); 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; } diff --git a/src/simulation/elements/WARP.cpp b/src/simulation/elements/WARP.cpp index 25dd885e0..8d669e8e3 100644 --- a/src/simulation/elements/WARP.cpp +++ b/src/simulation/elements/WARP.cpp @@ -67,12 +67,12 @@ int Element_WARP::update(UPDATE_FUNC_ARGS) 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) { - parts[i].x = parts[r>>8].x; - parts[i].y = parts[r>>8].y; - parts[r>>8].x = x; - parts[r>>8].y = y; - parts[r>>8].vx = (rand()%4)-1.5; - parts[r>>8].vy = (rand()%4)-2; + parts[i].x = parts[ID(r)].x; + parts[i].y = parts[ID(r)].y; + parts[ID(r)].x = x; + parts[ID(r)].y = y; + parts[ID(r)].vx = (rand()%4)-1.5; + parts[ID(r)].vy = (rand()%4)-2; parts[i].life += 4; pmap[y][x] = r; pmap[y+ry][x+rx] = (i<<8)|parts[i].type; diff --git a/src/simulation/elements/WATR.cpp b/src/simulation/elements/WATR.cpp index 7324a8bda..d55a06d9d 100644 --- a/src/simulation/elements/WATR.cpp +++ b/src/simulation/elements/WATR.cpp @@ -60,7 +60,7 @@ int Element_WATR::update(UPDATE_FUNC_ARGS) sim->part_change_type(i,x,y,PT_SLTW); // on average, convert 3 WATR to SLTW before SALT turns into SLTW 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)) { @@ -68,8 +68,8 @@ int Element_WATR::update(UPDATE_FUNC_ARGS) parts[i].life = 4; parts[i].ctype = PT_WATR; } - else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ - sim->kill_part(r>>8); + else if ((r&0xFF)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){ + sim->kill_part(ID(r)); if(!(rand()%30)){ sim->kill_part(i); 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 { part_change_type(i,x,y,PT_PSTE); - sim.kill_part(r>>8); + sim.kill_part(ID(r)); }*/ } return 0; diff --git a/src/simulation/elements/WIFI.cpp b/src/simulation/elements/WIFI.cpp index 35ba95b08..ff677c858 100644 --- a/src/simulation/elements/WIFI.cpp +++ b/src/simulation/elements/WIFI.cpp @@ -63,14 +63,14 @@ int Element_WIFI::update(UPDATE_FUNC_ARGS) // wireless[][1] - whether channel should be active on next frame if (sim->wireless[parts[i].tmp][0]) { - if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[r>>8].life==0 && sim->wireless[parts[i].tmp][0]) + if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[ID(r)].life==0 && sim->wireless[parts[i].tmp][0]) { - parts[r>>8].ctype = r&0xFF; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; + parts[ID(r)].ctype = r&0xFF; + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 4; } } - if ((r&0xFF)==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3) + if ((r&0xFF)==PT_SPRK && parts[ID(r)].ctype!=PT_NSCN && parts[ID(r)].life>=3) { sim->wireless[parts[i].tmp][1] = 1; sim->ISWIRE = 2; diff --git a/src/simulation/elements/WIRE.cpp b/src/simulation/elements/WIRE.cpp index 2c2ebcb0a..78d455bd5 100644 --- a/src/simulation/elements/WIRE.cpp +++ b/src/simulation/elements/WIRE.cpp @@ -74,14 +74,14 @@ int Element_WIRE::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3 && parts[r>>8].ctype==PT_PSCN) + if ((r&0xFF)==PT_SPRK && parts[ID(r)].life==3 && parts[ID(r)].ctype==PT_PSCN) { parts[i].ctype=1; return 0; } else if ((r&0xFF)==PT_NSCN && parts[i].tmp==1) sim->create_part(-1, x+rx, y+ry, PT_SPRK); - else if ((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp) + else if ((r&0xFF)==PT_WIRE && parts[ID(r)].tmp==1 && !parts[i].tmp) count++; } }