From 1ca39e1e7dc3659e4cb16aff515f30acfe88850d Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 9 Mar 2013 11:49:49 -0500 Subject: allow new searches even if tags haven't loaded fixes search buttons being enabled but not working until the tags list is loaded diff --git a/src/search/SearchModel.cpp b/src/search/SearchModel.cpp index 913e95b..f4de2d6 100644 --- a/src/search/SearchModel.cpp +++ b/src/search/SearchModel.cpp @@ -64,7 +64,7 @@ void * SearchModel::updateTagListT() void SearchModel::UpdateSaveList(int pageNumber, std::string query) { //Threading - if(!updateSaveListWorking && !updateTagListWorking) + if(!updateSaveListWorking) { lastQuery = query; lastError = ""; @@ -84,7 +84,7 @@ void SearchModel::UpdateSaveList(int pageNumber, std::string query) selected.clear(); notifySelectedChanged(); - if(GetShowTags() && !tagList.size()) + if(GetShowTags() && !tagList.size() && !updateTagListWorking) { updateTagListFinished = false; updateTagListWorking = true; diff --git a/src/search/SearchModel.h b/src/search/SearchModel.h index 9e93f05..0fe9480 100644 --- a/src/search/SearchModel.h +++ b/src/search/SearchModel.h @@ -48,7 +48,7 @@ private: bool updateTagListWorking; volatile bool updateTagListFinished; pthread_t updateTagListThread; - static void * updateTagListTHelper(void * obj); + static void * updateTagListTHelper(void * obj); void * updateTagListT(); public: SearchModel(); -- cgit v0.9.2-21-gd62e From e6f6eedd1364fd3792d6ca7aa3ac2d0c97911f70 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 9 Mar 2013 16:50:36 -0500 Subject: fix empty signs being created when shifting them out of bounds, draw parts of images when it goes partway off the top of the screen. diff --git a/src/graphics/RasterDrawMethods.inl b/src/graphics/RasterDrawMethods.inl index dec15f1..07b8257 100644 --- a/src/graphics/RasterDrawMethods.inl +++ b/src/graphics/RasterDrawMethods.inl @@ -362,6 +362,12 @@ void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int int i, j, r, g, b; if (!img) return; if(y + h > VIDYRES) h = ((VIDYRES)-y)-1; //Adjust height to prevent drawing off the bottom + if (y < 0 && -y < h) + { + img += -y*w; + h += y; + y = 0; + } if(!h || y < 0) return; if(a >= 255) for (j=0; jsize(); i++) delete saveComments->at(i); saveComments->clear(); + delete saveComments; saveComments = NULL; } notifySaveChanged(); @@ -166,6 +167,7 @@ void PreviewModel::UpdateComments(int pageNumber) { for(int i = 0; i < saveComments->size(); i++) delete saveComments->at(i); + saveComments->clear(); delete saveComments; saveComments = NULL; } @@ -314,6 +316,7 @@ PreviewModel::~PreviewModel() { for(int i = 0; i < saveComments->size(); i++) delete saveComments->at(i); saveComments->clear(); + delete saveComments; } saveDataBuffer.clear(); } diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index b6f4f84..3acf413 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -146,10 +146,13 @@ int Simulation::Load(int fullX, int fullY, GameSave * save) Element_PPIP::ppip_changed = 1; for(int i = 0; i < save->signs.size() && signs.size() < MAXSIGNS; i++) { - sign tempSign = save->signs[i]; - tempSign.x += fullX; - tempSign.y += fullY; - signs.push_back(tempSign); + if (save->signs[i].text[0]) + { + sign tempSign = save->signs[i]; + tempSign.x += fullX; + tempSign.y += fullY; + signs.push_back(tempSign); + } } for(int saveBlockX = 0; saveBlockX < save->blockWidth; saveBlockX++) { -- cgit v0.9.2-21-gd62e From a9e66429d60c0867e540d645a8c52db79abb1736 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Sat, 9 Mar 2013 22:47:08 -0500 Subject: Fix some memory issues when closing preview UI too fast. I'm not sure if this pthread usage is ideal, but it does seem to work on linux. diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 4c13850..577f78e 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -1594,16 +1594,19 @@ SaveInfo * Client::GetSave(int saveID, int saveDate) tempSave->Favourite = tempFavourite.Value(); tempSave->Views = tempViews.Value(); tempSave->Version = tempVersion.Value(); + free(data); return tempSave; } catch (json::Exception &e) { lastError = "Could not read response"; + free(data); return NULL; } } else { + if (data) free(data); lastError = http_ret_text(dataStatus); } return NULL; diff --git a/src/preview/PreviewModel.cpp b/src/preview/PreviewModel.cpp index 8a0ff59..f4cd6ec 100644 --- a/src/preview/PreviewModel.cpp +++ b/src/preview/PreviewModel.cpp @@ -38,27 +38,63 @@ void * PreviewModel::updateSaveCommentsTHelper(void * obj) void * PreviewModel::updateSaveInfoT() { + int check; + pthread_attr_t attr; SaveInfo * tempSave = Client::Ref().GetSave(tSaveID, tSaveDate); - updateSaveInfoFinished = true; - return tempSave; + pthread_getattr_np(pthread_self(), &attr); + pthread_attr_getdetachstate(&attr,&check); + pthread_attr_destroy(&attr); + if (check==PTHREAD_CREATE_JOINABLE) + { + updateSaveInfoFinished = true; + return tempSave; + } else + { + if (tempSave) delete tempSave; + } + return NULL; } void * PreviewModel::updateSaveDataT() { - int tempDataSize; + int tempDataSize, check; + pthread_attr_t attr; unsigned char * tempData = Client::Ref().GetSaveData(tSaveID, tSaveDate, tempDataSize); - saveDataBuffer.clear(); - if (tempData) - saveDataBuffer.insert(saveDataBuffer.begin(), tempData, tempData+tempDataSize); - updateSaveDataFinished = true; + pthread_getattr_np(pthread_self(), &attr); + pthread_attr_getdetachstate(&attr,&check); + pthread_attr_destroy(&attr); + if (check==PTHREAD_CREATE_JOINABLE) + { + saveDataBuffer.clear(); + if (tempData) + saveDataBuffer.insert(saveDataBuffer.begin(), tempData, tempData+tempDataSize); + updateSaveDataFinished = true; + } + if (tempData) free(tempData); + return NULL; } void * PreviewModel::updateSaveCommentsT() { + int check; + pthread_attr_t attr; std::vector * tempComments = Client::Ref().GetComments(tSaveID, (commentsPageNumber-1)*20, 20); - updateSaveCommentsFinished = true; - return tempComments; + pthread_getattr_np(pthread_self(), &attr); + pthread_attr_getdetachstate(&attr,&check); + pthread_attr_destroy(&attr); + if (check==PTHREAD_CREATE_JOINABLE) + { + updateSaveCommentsFinished = true; + return tempComments; + } else + { + for(int i = 0; i < tempComments->size(); i++) + delete tempComments->at(i); + tempComments->clear(); + delete tempComments; + } + return NULL; } void PreviewModel::SetFavourite(bool favourite) @@ -307,6 +343,12 @@ void PreviewModel::Update() } PreviewModel::~PreviewModel() { + //pthread_join(updateSaveDataThread, NULL); + //pthread_join(updateSaveInfoThread, NULL); + //pthread_join(updateSaveCommentsThread, NULL); + if (updateSaveDataWorking) pthread_detach(updateSaveDataThread); + if (updateSaveInfoWorking) pthread_detach(updateSaveInfoThread); + if (updateSaveCommentsWorking) pthread_detach(updateSaveCommentsThread); if(save) delete save; if(saveComments) @@ -314,6 +356,7 @@ PreviewModel::~PreviewModel() { for(int i = 0; i < saveComments->size(); i++) delete saveComments->at(i); saveComments->clear(); + delete saveComments; } saveDataBuffer.clear(); } -- cgit v0.9.2-21-gd62e From 5aa233d4e7ec0f87b59572d44b4e90cda2bb6272 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Sun, 10 Mar 2013 01:47:09 -0500 Subject: Use cancels instead of pthread_getattr_np for compatibility. Stopping the download would be nice, it still goes in the background. diff --git a/src/preview/PreviewModel.cpp b/src/preview/PreviewModel.cpp index b25d084..8d608cf 100644 --- a/src/preview/PreviewModel.cpp +++ b/src/preview/PreviewModel.cpp @@ -36,65 +36,63 @@ void * PreviewModel::updateSaveCommentsTHelper(void * obj) return ((PreviewModel*)obj)->updateSaveCommentsT(); } +void PreviewModel::updateSaveInfoTDelete(void * arg) +{ + delete arg; +} +void PreviewModel::updateSaveDataTDelete(void * arg) +{ + free(arg); +} +void PreviewModel::updateSaveCommentsTDelete(void * arg) +{ + for(int i = 0; i < ((std::vector *)arg)->size(); i++) + delete ((std::vector *)arg)->at(i); + ((std::vector *)arg)->clear(); + delete arg; +} + void * PreviewModel::updateSaveInfoT() { - int check; - pthread_attr_t attr; - SaveInfo * tempSave = Client::Ref().GetSave(tSaveID, tSaveDate); - pthread_getattr_np(pthread_self(), &attr); - pthread_attr_getdetachstate(&attr,&check); - pthread_attr_destroy(&attr); - if (check==PTHREAD_CREATE_JOINABLE) - { - updateSaveInfoFinished = true; - return tempSave; - } else - { - if (tempSave) delete tempSave; - } - return NULL; + SaveInfo * tempSave; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL); + tempSave = Client::Ref().GetSave(tSaveID, tSaveDate); + pthread_cleanup_push(&updateSaveInfoTDelete,tempSave); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); + pthread_testcancel(); + updateSaveInfoFinished = true; + pthread_cleanup_pop(0); + return tempSave; } void * PreviewModel::updateSaveDataT() { - int tempDataSize, check; - pthread_attr_t attr; - unsigned char * tempData = Client::Ref().GetSaveData(tSaveID, tSaveDate, tempDataSize); - pthread_getattr_np(pthread_self(), &attr); - pthread_attr_getdetachstate(&attr,&check); - pthread_attr_destroy(&attr); - if (check==PTHREAD_CREATE_JOINABLE) - { - saveDataBuffer.clear(); - if (tempData) - saveDataBuffer.insert(saveDataBuffer.begin(), tempData, tempData+tempDataSize); - updateSaveDataFinished = true; - } - if (tempData) free(tempData); - + int tempDataSize; + unsigned char * tempData; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL); + tempData = Client::Ref().GetSaveData(tSaveID, tSaveDate, tempDataSize); + pthread_cleanup_push(&updateSaveDataTDelete,tempData); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); + pthread_testcancel(); + saveDataBuffer.clear(); + if (tempData) + saveDataBuffer.insert(saveDataBuffer.begin(), tempData, tempData+tempDataSize); + updateSaveDataFinished = true; + pthread_cleanup_pop(1); return NULL; } void * PreviewModel::updateSaveCommentsT() { - int check; - pthread_attr_t attr; - std::vector * tempComments = Client::Ref().GetComments(tSaveID, (commentsPageNumber-1)*20, 20); - pthread_getattr_np(pthread_self(), &attr); - pthread_attr_getdetachstate(&attr,&check); - pthread_attr_destroy(&attr); - if (check==PTHREAD_CREATE_JOINABLE) - { - updateSaveCommentsFinished = true; - return tempComments; - } else - { - for(int i = 0; i < tempComments->size(); i++) - delete tempComments->at(i); - tempComments->clear(); - delete tempComments; - } - return NULL; + std::vector * tempComments; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL); + tempComments = Client::Ref().GetComments(tSaveID, (commentsPageNumber-1)*20, 20); + pthread_cleanup_push(&updateSaveCommentsTDelete,tempComments); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); + pthread_testcancel(); + updateSaveCommentsFinished = true; + pthread_cleanup_pop(0); + return tempComments; } void PreviewModel::SetFavourite(bool favourite) @@ -345,12 +343,9 @@ void PreviewModel::Update() } PreviewModel::~PreviewModel() { - //pthread_join(updateSaveDataThread, NULL); - //pthread_join(updateSaveInfoThread, NULL); - //pthread_join(updateSaveCommentsThread, NULL); - if (updateSaveDataWorking) pthread_detach(updateSaveDataThread); - if (updateSaveInfoWorking) pthread_detach(updateSaveInfoThread); - if (updateSaveCommentsWorking) pthread_detach(updateSaveCommentsThread); + pthread_cancel(updateSaveDataThread); + pthread_cancel(updateSaveInfoThread); + pthread_cancel(updateSaveCommentsThread); if(save) delete save; if(saveComments) diff --git a/src/preview/PreviewModel.h b/src/preview/PreviewModel.h index 2ee2c45..a8800e3 100644 --- a/src/preview/PreviewModel.h +++ b/src/preview/PreviewModel.h @@ -44,18 +44,21 @@ class PreviewModel { volatile bool updateSaveDataFinished; pthread_t updateSaveDataThread; static void * updateSaveDataTHelper(void * obj); + static void updateSaveDataTDelete(void * arg); void * updateSaveDataT(); bool updateSaveInfoWorking; volatile bool updateSaveInfoFinished; pthread_t updateSaveInfoThread; static void * updateSaveInfoTHelper(void * obj); + static void updateSaveInfoTDelete(void * arg); void * updateSaveInfoT(); bool updateSaveCommentsWorking; volatile bool updateSaveCommentsFinished; pthread_t updateSaveCommentsThread; static void * updateSaveCommentsTHelper(void * obj); + static void updateSaveCommentsTDelete(void * arg); void * updateSaveCommentsT(); public: PreviewModel(); -- cgit v0.9.2-21-gd62e From 85d6c127212140c9df2204eacabc338b924fe4ab Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 10 Mar 2013 22:08:00 -0400 Subject: fix stamp thumbnails not showing until you move the mouse, add a few new[]'s replacing some .c_str() pointers in client.cpp diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 577f78e..9496349 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -121,7 +121,12 @@ void Client::Initialise(std::string proxyString) } if(proxyString.length()) - http_init((char*)proxyString.c_str()); + { + char *proxy = new char[proxyString.length() + 1]; + std::strcpy (proxy, proxyString.c_str()); + http_init(proxy); + delete[] proxy; + } else http_init(NULL); @@ -144,7 +149,14 @@ void Client::Initialise(std::string proxyString) if(authUser.ID) { - http_auth_headers(versionCheckRequest, (char *)format::NumberToString(authUser.ID).c_str(), NULL, (char *)authUser.SessionID.c_str()); + std::string idTempString = format::NumberToString(authUser.ID); + char *id = new char[idTempString.length() + 1]; + std::strcpy (id, idTempString.c_str()); + char *session = new char[authUser.SessionID.length() + 1]; + std::strcpy (session, authUser.SessionID.c_str()); + http_auth_headers(versionCheckRequest, id, NULL, session); + delete[] id; + delete[] session; } } @@ -404,7 +416,12 @@ void Client::SetProxy(std::string proxy) { http_done(); if(proxy.length()) - http_init((char*)proxy.c_str()); + { + char *tempproxy = new char[proxy.length() + 1]; + std::strcpy (tempproxy, proxy.c_str()); + http_init(tempproxy); + delete[] tempproxy; + } else http_init(NULL); } @@ -861,18 +878,24 @@ RequestStatus Client::UploadSave(SaveInfo & save) } char *saveName = new char[save.GetName().length() + 1]; - std::strcpy ( saveName, save.GetName().c_str() ); + std::strcpy (saveName, save.GetName().c_str()); char *saveDescription = new char[save.GetDescription().length() + 1]; - std::strcpy ( saveDescription, save.GetDescription().c_str() ); + std::strcpy (saveDescription, save.GetDescription().c_str()); + char *userid = new char[userIDStream.str().length() + 1]; + std::strcpy (userid, userIDStream.str().c_str()); + char *session = new char[authUser.SessionID.length() + 1]; + std::strcpy (session, authUser.SessionID.c_str()); char * postNames[] = { "Name", "Description", "Data:save.bin", "Publish", NULL }; char * postDatas[] = { saveName, saveDescription, gameData, (char *)(save.GetPublished()?"Public":"Private") }; int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 }; //std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl; - data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); + data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength); delete[] saveDescription; delete[] saveName; + delete[] userid; + delete[] session; } else { @@ -1075,17 +1098,28 @@ RequestStatus Client::ExecVote(int saveID, int direction) std::stringstream idStream; idStream << saveID; - std::string saveIDText = format::NumberToString(saveID); - std::string directionText = direction==1?"Up":"Down"; - - std::string userIDText = format::NumberToString(authUser.ID); if(authUser.ID) { + char * directionText = direction==1?"Up":"Down"; + std::string saveIDText = format::NumberToString(saveID); + std::string userIDText = format::NumberToString(authUser.ID); + + char *id = new char[saveIDText.length() + 1]; + std::strcpy (id, saveIDText.c_str()); + char *userid = new char[userIDText.length() + 1]; + std::strcpy (userid, userIDText.c_str()); + char *session = new char[authUser.SessionID.length() + 1]; + std::strcpy (session, authUser.SessionID.c_str()); + char * postNames[] = { "ID", "Action", NULL }; - char * postDatas[] = { (char*)(saveIDText.c_str()), (char*)(directionText.c_str()) }; - int postLengths[] = { saveIDText.length(), directionText.length() }; + char * postDatas[] = { id, directionText }; + int postLengths[] = { saveIDText.length(), strlen(directionText) }; //std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl; - data = http_multipart_post("http://" SERVER "/Vote.api", postNames, postDatas, postLengths, (char *)(userIDText.c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength); + data = http_multipart_post("http://" SERVER "/Vote.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength); + + delete[] id; + delete[] userid; + delete[] session; } else { @@ -1127,7 +1161,11 @@ unsigned char * Client::GetSaveData(int saveID, int saveDate, int & dataLength) urlStream << "http://" << STATICSERVER << "/" << saveID << ".cps"; } - data = (unsigned char *)http_simple_get((char *)urlStream.str().c_str(), &dataStatus, &dataLength); + char *url = new char[urlStream.str().length() + 1]; + std::strcpy (url, urlStream.str().c_str()); + data = (unsigned char *)http_simple_get(url, &dataStatus, &dataLength); + delete[] url; + if(data && dataStatus == 200) { return data; diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index d302dce..8b381e2 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1038,21 +1038,20 @@ void GameView::OnMouseUp(int x, int y, unsigned button) { if(selectMode==PlaceSave) { - Thumbnail * tempThumb = placeSaveThumb; - if(tempThumb) + if(placeSaveThumb) { - int thumbX = selectPoint2.X - (tempThumb->Size.X/2); - int thumbY = selectPoint2.Y - (tempThumb->Size.Y/2); + int thumbX = selectPoint2.X - (placeSaveThumb->Size.X/2); + int thumbY = selectPoint2.Y - (placeSaveThumb->Size.Y/2); if(thumbX<0) thumbX = 0; - if(thumbX+(tempThumb->Size.X)>=XRES) - thumbX = XRES-tempThumb->Size.X; + if(thumbX+(placeSaveThumb->Size.X)>=XRES) + thumbX = XRES-placeSaveThumb->Size.X; if(thumbY<0) thumbY = 0; - if(thumbY+(tempThumb->Size.Y)>=YRES) - thumbY = YRES-tempThumb->Size.Y; + if(thumbY+(placeSaveThumb->Size.Y)>=YRES) + thumbY = YRES-placeSaveThumb->Size.Y; c->PlaceSave(ui::Point(thumbX, thumbY)); } @@ -1388,13 +1387,13 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool if(ctrl) { c->LoadClipboard(); - selectPoint2 = ui::Point(-1, -1); + selectPoint2 = mousePosition; selectPoint1 = selectPoint2; } break; case 'l': c->LoadStamp(); - selectPoint2 = ui::Point(-1, -1); + selectPoint2 = mousePosition; selectPoint1 = selectPoint2; isMouseDown = false; drawMode = DrawPoints; @@ -1696,6 +1695,7 @@ void GameView::NotifyPlaceSaveChanged(GameModel * sender) { placeSaveThumb = SaveRenderer::Ref().Render(sender->GetPlaceSave()); selectMode = PlaceSave; + selectPoint2 = mousePosition; } else { @@ -1850,27 +1850,26 @@ void GameView::OnDraw() { if(selectMode==PlaceSave) { - Thumbnail * tempThumb = placeSaveThumb; - if(tempThumb && selectPoint2.X!=-1) + if(placeSaveThumb && selectPoint2.X!=-1) { - int thumbX = selectPoint2.X - (tempThumb->Size.X/2); - int thumbY = selectPoint2.Y - (tempThumb->Size.Y/2); + int thumbX = selectPoint2.X - (placeSaveThumb->Size.X/2); + int thumbY = selectPoint2.Y - (placeSaveThumb->Size.Y/2); ui::Point thumbPos = c->NormaliseBlockCoord(ui::Point(thumbX, thumbY)); if(thumbPos.X<0) thumbPos.X = 0; - if(thumbPos.X+(tempThumb->Size.X)>=XRES) - thumbPos.X = XRES-tempThumb->Size.X; + if(thumbPos.X+(placeSaveThumb->Size.X)>=XRES) + thumbPos.X = XRES-placeSaveThumb->Size.X; if(thumbPos.Y<0) thumbPos.Y = 0; - if(thumbPos.Y+(tempThumb->Size.Y)>=YRES) - thumbPos.Y = YRES-tempThumb->Size.Y; + if(thumbPos.Y+(placeSaveThumb->Size.Y)>=YRES) + thumbPos.Y = YRES-placeSaveThumb->Size.Y; - ren->draw_image(tempThumb->Data, thumbPos.X, thumbPos.Y, tempThumb->Size.X, tempThumb->Size.Y, 128); + ren->draw_image(placeSaveThumb->Data, thumbPos.X, thumbPos.Y, placeSaveThumb->Size.X, placeSaveThumb->Size.Y, 128); - ren->xor_rect(thumbPos.X, thumbPos.Y, tempThumb->Size.X, tempThumb->Size.Y); + ren->xor_rect(thumbPos.X, thumbPos.Y, placeSaveThumb->Size.X, placeSaveThumb->Size.Y); } } else -- cgit v0.9.2-21-gd62e From a65d93523d98d33cc8964a905c06976dfb5d8a9e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 10 Mar 2013 23:21:28 -0400 Subject: fix small free/delete mismatch / a warning diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 9496349..af650a9 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -1021,7 +1021,7 @@ std::string Client::AddStamp(GameSave * saveData) stampStream.write((const char *)gameData, gameDataLength); stampStream.close(); - free(gameData); + delete gameData; stampIDs.push_front(saveID.str()); @@ -1100,7 +1100,7 @@ RequestStatus Client::ExecVote(int saveID, int direction) if(authUser.ID) { - char * directionText = direction==1?"Up":"Down"; + char * directionText = (char*)(direction==1?"Up":"Down"); std::string saveIDText = format::NumberToString(saveID); std::string userIDText = format::NumberToString(authUser.ID); -- cgit v0.9.2-21-gd62e From 2caa240d9db7f9957d916ce078774cba3049a82f Mon Sep 17 00:00:00 2001 From: cracker64 Date: Sun, 10 Mar 2013 23:23:17 -0400 Subject: Delete thumbnails on close. diff --git a/src/client/ThumbnailBroker.cpp b/src/client/ThumbnailBroker.cpp index 85fee3a..390af13 100644 --- a/src/client/ThumbnailBroker.cpp +++ b/src/client/ThumbnailBroker.cpp @@ -27,7 +27,10 @@ ThumbnailBroker::ThumbnailBroker() ThumbnailBroker::~ThumbnailBroker() { - + for(std::deque >::iterator iter = thumbnailCache.begin(), end = thumbnailCache.end(); iter != end; ++iter) + { + delete (*iter).second; + } } void ThumbnailBroker::assureRunning() @@ -389,4 +392,4 @@ void ThumbnailBroker::DetachThumbnailListener(ThumbnailListener * tListener) } pthread_mutex_unlock(&listenersMutex); -} \ No newline at end of file +} -- cgit v0.9.2-21-gd62e From 319ffb7e77bfce648f085a1ecc8275dee57ece05 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Mon, 11 Mar 2013 17:34:49 -0400 Subject: Change some old NEUTPENETRATE to NEUTPASS, NEUT should only displace GOO, WOOD, and PLNT. diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 3acf413..f037252 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2108,7 +2108,6 @@ void Simulation::init_can_move() } can_move[PT_ELEC][PT_LCRY] = 2; can_move[PT_ELEC][PT_EXOT] = 2; - can_move[PT_NEUT][PT_EXOT] = 2; can_move[PT_PHOT][PT_LCRY] = 3;//varies according to LCRY life can_move[PT_PHOT][PT_BIZR] = 2; @@ -2118,7 +2117,6 @@ void Simulation::init_can_move() can_move[PT_PHOT][PT_BIZRS] = 2; can_move[PT_ELEC][PT_BIZRS] = 2; - can_move[PT_NEUT][PT_INVIS] = 2; //whol eats anar can_move[PT_ANAR][PT_WHOL] = 1; can_move[PT_ANAR][PT_NWHL] = 1; diff --git a/src/simulation/elements/DEUT.cpp b/src/simulation/elements/DEUT.cpp index 98f27a5..fb58700 100644 --- a/src/simulation/elements/DEUT.cpp +++ b/src/simulation/elements/DEUT.cpp @@ -31,7 +31,7 @@ Element_DEUT::Element_DEUT() Description = "Deuterium oxide. Volume changes with temp, radioactive with neutrons."; State = ST_LIQUID; - Properties = TYPE_LIQUID|PROP_NEUTPENETRATE; + Properties = TYPE_LIQUID|PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp index cca1b68..c6f1aca 100644 --- a/src/simulation/elements/DSTW.cpp +++ b/src/simulation/elements/DSTW.cpp @@ -31,7 +31,7 @@ Element_DSTW::Element_DSTW() Description = "Distilled water, does not conduct electricity."; State = ST_LIQUID; - Properties = TYPE_LIQUID|PROP_NEUTPENETRATE; + Properties = TYPE_LIQUID|PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp index 140383c..1b763ca 100644 --- a/src/simulation/elements/EXOT.cpp +++ b/src/simulation/elements/EXOT.cpp @@ -31,7 +31,7 @@ Element_EXOT::Element_EXOT() Description = "Exotic matter. Explodes with excess exposure to electrons."; State = ST_LIQUID; - Properties = TYPE_LIQUID; + Properties = TYPE_LIQUID|PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/GAS.cpp b/src/simulation/elements/GAS.cpp index 45aee8d..45bcf3e 100644 --- a/src/simulation/elements/GAS.cpp +++ b/src/simulation/elements/GAS.cpp @@ -31,7 +31,7 @@ Element_GAS::Element_GAS() Description = "Gas. Diffuses. Flammable. Liquefies under pressure."; State = ST_GAS; - Properties = TYPE_GAS | PROP_NEUTPENETRATE; + Properties = TYPE_GAS | PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; @@ -46,4 +46,4 @@ Element_GAS::Element_GAS() } -Element_GAS::~Element_GAS() {} \ No newline at end of file +Element_GAS::~Element_GAS() {} diff --git a/src/simulation/elements/ICEI.cpp b/src/simulation/elements/ICEI.cpp index b3d64d1..95210bb 100644 --- a/src/simulation/elements/ICEI.cpp +++ b/src/simulation/elements/ICEI.cpp @@ -31,7 +31,7 @@ Element_ICEI::Element_ICEI() Description = "Solid. Freezes water. Crushes under pressure. Cools down air."; State = ST_SOLID; - Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_NEUTPENETRATE; + Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/OIL.cpp b/src/simulation/elements/OIL.cpp index 42be14e..a397ab8 100644 --- a/src/simulation/elements/OIL.cpp +++ b/src/simulation/elements/OIL.cpp @@ -31,7 +31,7 @@ Element_OIL::Element_OIL() Description = "Liquid. Flammable."; State = ST_LIQUID; - Properties = TYPE_LIQUID | PROP_NEUTPENETRATE; + Properties = TYPE_LIQUID | PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; @@ -46,4 +46,4 @@ Element_OIL::Element_OIL() } -Element_OIL::~Element_OIL() {} \ No newline at end of file +Element_OIL::~Element_OIL() {} diff --git a/src/simulation/elements/PLUT.cpp b/src/simulation/elements/PLUT.cpp index 9f5f806..282de46 100644 --- a/src/simulation/elements/PLUT.cpp +++ b/src/simulation/elements/PLUT.cpp @@ -31,7 +31,7 @@ Element_PLUT::Element_PLUT() Description = "Heavy particles. Fissile. Generates neutrons under pressure."; State = ST_SOLID; - Properties = TYPE_PART|PROP_NEUTPENETRATE|PROP_RADIOACTIVE; + Properties = TYPE_PART|PROP_NEUTPASS|PROP_RADIOACTIVE; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/SNOW.cpp b/src/simulation/elements/SNOW.cpp index 9e12e0a..2077ae8 100644 --- a/src/simulation/elements/SNOW.cpp +++ b/src/simulation/elements/SNOW.cpp @@ -31,7 +31,7 @@ Element_SNOW::Element_SNOW() Description = "Light particles."; State = ST_SOLID; - Properties = TYPE_PART|PROP_LIFE_DEC|PROP_NEUTPENETRATE; + Properties = TYPE_PART|PROP_LIFE_DEC|PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/WATR.cpp b/src/simulation/elements/WATR.cpp index 513ab60..4faf8dc 100644 --- a/src/simulation/elements/WATR.cpp +++ b/src/simulation/elements/WATR.cpp @@ -31,7 +31,7 @@ Element_WATR::Element_WATR() Description = "Liquid. Conducts electricity. Freezes. Extinguishes fires."; State = ST_LIQUID; - Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE; + Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPASS; LowPressure = IPL; LowPressureTransition = NT; -- cgit v0.9.2-21-gd62e From 134d1fab10a713ce0e99bfc3325b099abcbbe591 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 12 Mar 2013 15:00:51 -0400 Subject: delete ancient changelog.txt diff --git a/Changelog.txt b/Changelog.txt deleted file mode 100644 index 5b06236..0000000 --- a/Changelog.txt +++ /dev/null @@ -1,19 +0,0 @@ - - Special brush types - - Special brush delete - - LOVE - - LOLZ - - Property edit - - Saving, loading, thumbnailing, etc - - HEAT/COOL - - Streamlines - - Grid - - Sign moving - - Electron fancyness with glass, fire_r-g-b now out of scope - - Grav fancyness, use current frame index to determine colour, not globals! - - Emp flash - - Stickman HP - - To do: - See TODO's - Char * and string, hmm.... - Vectors for things like signs, stamp list, etc where appropriate \ No newline at end of file diff --git a/README b/README index 359ed7c..a98ee4e 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -The Powder Toy - November 2012 +The Powder Toy - March 2013 Get the latest version here: http://powdertoy.co.uk/Download.html diff --git a/src/interface/Window.cpp b/src/interface/Window.cpp index e36f9c1..3cd22e6 100644 --- a/src/interface/Window.cpp +++ b/src/interface/Window.cpp @@ -408,7 +408,7 @@ void Window::DoMouseDown(int x_, int y_, unsigned button) if(!stop) OnMouseDown(x_, y_, button); - if(x_ < Position.X || y_ < Position.Y || x_ > Position.X+Size.X || y_ > Position.Y+Size.Y) + if(!clickState && (x_ < Position.X || y_ < Position.Y || x_ > Position.X+Size.X || y_ > Position.Y+Size.Y)) OnTryExit(MouseOutside); if(destruct) -- cgit v0.9.2-21-gd62e