fix pcap description is NULL,then return immediately

--- src/main.cpp
+++ src/main.cpp
@@ -188,7 +188,7 @@
 	for (d = alldevs, i = 1; d; d = d->next, i++) {

 		cout << i << ". "
-			<< setiosflags(ios_base::left) << setw(40) << d->description
+			<< setiosflags(ios_base::left) << setw(40) << (char *)((d->description != 0)? d->description:"NULL")
 			<< "\t[" << d->name << ']' << endl;
 	}
 	cout << endl;


Increased initial PoS difficulty on mainnet

Result is about 1-2 blocks per minute

--- src/main.cpp
+++ src/main.cpp
@@ -31,7 +31,7 @@
 uint256 hashGenesisBlock = hashGenesisBlockOfficial;
 static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20);
 static CBigNum bnInitialHashTarget(~uint256(0) >> 24);
-static CBigNum bnInitialProofOfStakeHashTarget(~uint256(0) >> 20);
+static CBigNum bnInitialProofOfStakeHashTarget(~uint256(0) >> 30);
 unsigned int nStakeMinAge = STAKE_MIN_AGE;
 int nCoinbaseMaturity = COINBASE_MATURITY;
 int nCoinstakeMaturity = COINSTAKE_MATURITY;


Rate limiter error message moved to the 'mempool' category

--- src/main.cpp
+++ src/main.cpp
@@ -1790,9 +1790,10 @@
                 nLastTime = nNow;
                 // -limitfreerelay unit is thousand-bytes-per-minute
                 // At default rate it would take over a month to fill 1GB
-                if (dFreeCount >= GetArg("-limitfreerelay", 0) * 10 * 1000)
-                    return state.DoS(0, error("AcceptToMemoryPool : free transaction rejected by rate limiter"),
-                        REJECT_INSUFFICIENTFEE, "rate limited free transaction");
+                if (dFreeCount >= GetArg("-limitfreerelay", 0) * 10 * 1000) {
+                    LogPrint("mempool", "Free transaction %s rejected by rate limiter\n", tx.GetHash().GetHex());
+                    return false;
+                }
                 LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount + nSize);
                 dFreeCount += nSize;
             }


Add object latency to is_analysis().

Add object latency to is_analysis().

--- src/main.cpp
+++ src/main.cpp
@@ -90,7 +90,8 @@
         GetOption(ANALYSIS_LATENCY)->as<bool>() ||
         GetOption(ANALYSIS_BANDWIDTH)->as<bool>() ||
         !GetOption(ANALYSIS_WINDOWED_BANDWIDTH)->as<String>().empty() ||
-        GetOption(ANALYSIS_OSEG)->as<bool>() )
+        GetOption(ANALYSIS_OSEG)->as<bool>() ||
+        GetOption(ANALYSIS_OBJECT_LATENCY)->as<bool>() )
         return true;

     return false;


only kick a node for lots of xthin requests in mainnet -- other networks can produce lots of blocks

--- src/main.cpp
+++ src/main.cpp
@@ -5166,11 +5166,15 @@
             pfrom->nGetXthinLastTime = nNow;
             pfrom->nGetXthinCount += 1;
             LogPrint("thin", "nGetXthinCount is %f\n", pfrom->nGetXthinCount);
-            if (pfrom->nGetXthinCount >= 20) {
-                LogPrintf("DOS: Misbehaving - requesting too many get_xthin - disconnecting\n");
-                LOCK(cs_main);
-                Misbehaving(pfrom->GetId(), 100);  // If they exceed the limit then disconnect them
-            }
+            if (chainparams.NetworkIDString()=="main") // other networks have variable mining rates
+	      {
+		if (pfrom->nGetXthinCount >= 20)
+                {
+		  LogPrintf("DOS: Misbehaving - requesting too many get_xthin - disconnecting\n");
+		  LOCK(cs_main);
+		  Misbehaving(pfrom->GetId(), 100);  // If they exceed the limit then disconnect them
+		}
+	      }
         }

         CBloomFilter filterMemPool;


adding from old sembros

adding from old sembros

--- src/main.cpp
+++ src/main.cpp
@@ -2393,6 +2393,28 @@

         if (!mapProofOfStake.count(hash)) // add to mapProofOfStake
             mapProofOfStake.insert(make_pair(hash, hashProofOfStake));
+    }
+
+    CBlockIndex* pcheckpoint = Checkpoints::GetLastSyncCheckpoint();
+    if (pcheckpoint && pblock->hashPrevBlock != hashBestChain && !Checkpoints::WantedByPendingSyncCheckpoint(hash))
+    {
+        // Extra checks to prevent "fill up memory by spamming with bogus blocks"
+        int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
+        CBigNum bnNewBlock;
+        bnNewBlock.SetCompact(pblock->nBits);
+        CBigNum bnRequired;
+
+        if (pblock->IsProofOfStake())
+            bnRequired.SetCompact(ComputeMinStake(GetLastBlockIndex(pcheckpoint, true)->nBits, deltaTime, pblock->nTime));
+        else
+            bnRequired.SetCompact(ComputeMinWork(GetLastBlockIndex(pcheckpoint, false)->nBits, deltaTime));
+
+        if (bnNewBlock > bnRequired)
+        {
+            if (pfrom)
+                pfrom->Misbehaving(100);
+            return error("ProcessBlock() : block with too little %s", pblock->IsProofOfStake()? "proof-of-stake" : "proof-of-work");
+        }
     }

     // Ask for pending sync-checkpoint if any


allow to give a list of format to try

allow to give a list of format to try

--- src/main.cpp
+++ src/main.cpp
@@ -371,7 +371,7 @@
 {
 	// default parameters
 	const char *dev_name = "/dev/video0";
-	int format = V4L2_PIX_FMT_H264;
+	std::list<unsigned int> formatList;
 	int width = 640;
 	int height = 480;
 	int queueSize = 10;
@@ -396,6 +396,7 @@
 	std::list<std::string> userPasswordList;
 	int audioFreq = 44100;
 	int audioNbChannels = 2;
+	unsigned int format = ~0;
 #ifdef HAVE_ALSA
 	snd_pcm_format_t audioFmt = SND_PCM_FORMAT_S16_BE;
 #endif
@@ -434,7 +435,7 @@
 			case 'r':	ioTypeIn  = V4l2Access::IOTYPE_READWRITE; break;
 			case 'w':	ioTypeOut = V4l2Access::IOTYPE_READWRITE; break;
 			case 's':	useThread =  false; break;
-			case 'f':	format    = decodeVideoFormat(optarg); break;
+			case 'f':	format    = decodeVideoFormat(optarg); if (format) {formatList.push_back(format);};  break;
 			case 'F':	fps       = atoi(optarg); break;
 			case 'W':	width     = atoi(optarg); break;
 			case 'H':	height    = atoi(optarg); break;
@@ -509,7 +510,14 @@
 	{
 		devList.push_back(dev_name);
 	}
-
+
+	// default format tries
+	if ((formatList.empty()) && (format!=0)) {
+		std::cout << "use default format H264/MJPEG" << std::endl;
+		formatList.push_back(V4L2_PIX_FMT_H264);
+		formatList.push_back(V4L2_PIX_FMT_MJPEG);
+	}
+
 	// init logger
 	initLogger(verbose);

@@ -562,7 +570,7 @@
 				// Init video capture
 				LOG(NOTICE) << "Create V4L2 Source..." << videoDev;

-				V4L2DeviceParameters param(videoDev.c_str(), format, width, height, fps, verbose);
+				V4L2DeviceParameters param(videoDev.c_str(), formatList, width, height, fps, verbose);
 				V4l2Capture* videoCapture = V4l2Capture::create(param, ioTypeIn);
 				if (videoCapture)
 				{


Changed main file to accept the test function

--- src/main.cpp
+++ src/main.cpp
@@ -5,9 +5,11 @@
 #include <stdio.h>
 #include <sys/wait.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <stdlib.h>
 #include <vector>
 #include <stack>
+#include <cstring>

 using namespace std;
 using namespace boost;
@@ -163,6 +165,113 @@
     }
 }

+//-----------------------------------------------------------------------------
+void test_func(vector <char*> to_test)
+{
+	//cout << "detects [] or test" << endl;
+	string e_delim = "-e";
+	char* ed = const_cast<char*>(e_delim.c_str());
+	string f_delim = "-f";
+	char* fd = const_cast<char*>(f_delim.c_str());
+	string d_delim = "-d";
+	char* dd = const_cast<char*>(d_delim.c_str());
+	if (strcmp(to_test.at(1), ed) == 0)
+	{
+		struct stat buffer;
+		//cout << "there we go E" << endl;
+		int statusstat = stat(to_test.at(2), &buffer);
+		//cout << "Status of stat: " << statusstat << endl;
+		if (statusstat == 0)
+		{
+			cout << "(true)" << endl;
+			cout << "Path: Exists." << endl;
+		}
+		else
+		{
+			cout << "(false)" << endl;
+			cout << "Path: Does not exist." << endl;
+		}
+	}
+	else if (strcmp(to_test.at(1), fd) == 0)
+	{
+		//cout << "there we go F" << endl;
+		struct stat buffer;
+		stat(to_test.at(2), &buffer);
+		//cout << "Status of stat: " << statusstat << endl;
+		bool tempbool = S_ISREG(buffer.st_mode);
+		if (tempbool)
+		{
+			cout << "(true)" << endl;
+			cout << "Filename: Is regular file." << endl;
+		}
+		else
+		{
+			cout << "(false)" << endl;
+			cout << "Filename: Is not regular file." << endl;
+		}
+	}
+	else if (strcmp(to_test.at(1), dd) == 0)
+	{
+		//cout << "there we go D" << endl;
+		struct stat buffer;
+		stat(to_test.at(2), &buffer);
+		//cout << "Status of stat: " << statusstat << endl;
+		bool tempbool = S_ISDIR(buffer.st_mode);
+		if (tempbool)
+		{
+			cout << "(true)" << endl;
+			cout << "Filename: Is a directory." << endl;
+		}
+		else
+		{
+			cout << "(false)" << endl;
+			cout << "Filename: Is not a directory." << endl;
+		}
+	}
+	else if (to_test.size() == 2)
+	{
+		//cout << "auto set: E" << endl;
+		struct stat buffer;
+		int statusstat = stat(to_test.at(1), &buffer);
+		//cout << "Status of stat: " << statusstat << endl;
+		if (statusstat == 0)
+		{
+			cout << "(true)" << endl;
+			cout << "Path: Exists." << endl;
+		}
+		else
+		{
+			cout << "(false)" << endl;
+			cout << "Path: Does not exist." << endl;
+		}
+	}
+	else if (to_test.size() == 1)
+	{
+		cout << "Error: invalid use of test" << endl;
+	}
+	else
+	{
+		//cout << "auto set: E" << endl;
+		struct stat buffer;
+		int statusstat = stat(to_test.at(2), &buffer);
+		//cout << "Status of stat: " << statusstat << endl;
+		if (statusstat == 0)
+		{
+			cout << "(true)" << endl;
+			cout << "Path: Exists." << endl;
+		}
+		else
+		{
+			cout << "(false)" << endl;
+			cout << "Path: Does not exist." << endl;
+		}
+	}
+
+
+
+}
+//-------------------------------------------------------------------------------
+
 //main run function, will prepare the command line
 void run()
 {
@@ -193,7 +302,16 @@
 			vector< vector<string> > cmdline2;
             token(cmdline, cmdline2);
             vector< vector<char*> > commands;
-
+			//-------------------------------------------------------------------------
+			//changes
+			string test1 = "test";
+			char* test2 = const_cast<char*>(test1.c_str());
+			string test_openb = "[";
+			string test_closedb = "]";
+			char* test3 = const_cast<char*>(test_openb.c_str());
+			char* test4 = const_cast<char*>(test_closedb.c_str());
+			//-------------------------------------------------------------------------
+
 			//changes all strings to char pointers
 			int size = cmdline2.size();
 			for (int i = 0; i < size; ++i)
@@ -206,6 +324,16 @@
 					//cout << "before conversion to char*: " << cmdline2.at(i).at(j) << endl;
 					//cout << "during conversion to char*: " << cmdline2.at(i).at(j).c_str() << endl;
 					commands.at(i).push_back(const_cast<char*>(cmdline2.at(i).at(j).c_str()));
+					/*--------------------------------------------------------------------------
+					if (strcmp(commands.at(i).at(0), test2) == 0)
+					{
+						cout << "Hello there!" << " " << commands.at(i).at(0) << endl;
+					}
+					else if (strcmp(commands.at(i).at(0), test3) == 0)
+					{
+						cout << "Hello there!" << " " << commands.at(i).at(0) << endl;
+					}
+					*///-------------------------------------------------------------------------
 				}
 				char* temp = NULL;
 				commands.at(i).push_back(temp);
@@ -217,107 +345,137 @@
          	bool sentinel = true;
           	while (sentinel == true)
            	{
-				if (commands.size() == 1)
+				if (strcmp(commands.at(i).at(0), test3) == 0)
 				{
-					pid_t pid = fork();
-					if (pid == 0)
+					char* tempcharp = commands.at(i).at(commands.at(i).size() - 1);
+					if (strcmp(tempcharp, test4) == 0)
 					{
-						if (execvp(commands.at(i).at(0), &(commands.at(i).at(0))) == -1)
-						{
-							perror("exec");
-						}
-					}
-					if (pid > 0)
+						test_func(commands.at(i));
+					}
+					++i;
+					++j;
+					if (i == commands.size())
 					{
-						if (wait(0) == -1)
-						{
-							perror("wait");
-						}
-					}
-					sentinel = false;
+						break;
+					}
+				}
+				else if (strcmp(commands.at(i).at(0), test2) == 0)
+				{
+					test_func(commands.at(i));
+					++i;
+					++j;
+					if (i == commands.size())
+					{
+						break;
+					}
 				}
 				else
-				{
-					if (j == connectors.size())
+				{
+					if (commands.size() == 1)
 					{
-						--j;
-					}
-					//checks for connector logic
-					string temp = commands.at(i).at(0);
-					string tempconnectors = connectors.at(j);
-					if (temp.compare("exit") == 0)
-					{
-						exit(0);
-					}
-					//forking process to child
-					pid_t pid = fork();
-					if (pid == 0)
-					{
-						if (execvp(commands.at(i).at(0), &(commands.at(i).at(0))) == -1)
-						{
-							if (tempconnectors.compare("&&") == 0)
+						pid_t pid = fork();
+						if (pid == 0)
+						{
+							//--------------------------------------------------------------------------
+							int tempexec = execvp(commands.at(i).at(0), &(commands.at(i).at(0)));
+							if (tempexec == -1)
+							{
+								perror("exec");
+							}
+							//-----------------------
+						}
+						if (pid > 0)
+						{
+							if (wait(0) == -1)
 							{
-								++i;
-								++j;
-								if (i < commands.size())
+								perror("wait");
+							}
+						}
+						sentinel = false;
+					}
+					else
+					{
+						if (j == connectors.size())
+						{
+							--j;
+						}
+						//checks for connector logic
+						string temp = commands.at(i).at(0);
+						string tempconnectors = connectors.at(j);
+						if (temp.compare("exit") == 0)
+						{
+							exit(0);
+						}
+						//forking process to child
+						pid_t pid = fork();
+						if (pid == 0)
+						{
+							if (execvp(commands.at(i).at(0), &(commands.at(i).at(0))) == -1)
+							{
+								if (tempconnectors.compare("&&") == 0)
 								{
-									continue;
+									++i;
+									++j;
+									if (i < commands.size())
+									{
+										continue;
+									}
+									//else
+									//{
+									//	sentinel = false;
+									//}
 								}
-								//else
-								//{
-								//	sentinel = false;
-								//}
+								perror("exec");
 							}
-							perror("exec");
-						}
-					}
-					if (pid > 0)
-					{
-						int stats;
-						if (wait(&stats) == -1)
-						{
-							perror("wait");
-						}
-						else if (WEXITSTATUS(stats) == 0)
-						{
-							if ( (tempconnectors.compare("||") == 0) )
+						}
+						if (pid > 0)
+						{
+							int stats;
+							if (wait(&stats) == -1)
 							{
-								++i;
-								++i;
-								++j;
-								++j;
-								if (j < connectors.size())
+								perror("wait");
+							}
+							else if (WEXITSTATUS(stats) == 0)
+							{
+								if ( (tempconnectors.compare("||") == 0) )
 								{
-									tempconnectors = connectors.at(j);
-									if (tempconnectors.compare("||") == 0)
+									++i;
+									++i;
+									++j;
+									++j;
+									if (j < connectors.size())
 									{
-										++i;
-										++j;
+										tempconnectors = connectors.at(j);
+										if (tempconnectors.compare("||") == 0)
+										{
+											++i;
+											++j;
+										}
+									}
+									if (i >= commands.size())
+									{
+										sentinel = false;
+									}
+									else
+									{
+										continue;
 									}
 								}
-								if (i >= commands.size())
-								{
-									sentinel = false;
-								}
-								else
-								{
-									continue;
-								}
 							}
 						}
-					}
-					if (i >= connectors.size())
-					{
-						sentinel = false;
-					}
-					++i;
-					++j;
+						if (i >= connectors.size())
+						{
+							sentinel = false;
+						}
+						++i;
+						++j;
+					}
 				}
            	}
 		}
 	}
 }
-
+/*
 void parser(string command, vector<string> &cmd)
 {
     stack<int> parenthesis;
@@ -357,7 +515,7 @@
     }//end if no firstParent

 }//end of parser function
-
+*/
 //main function, will contain test cases
 int main()
 {


Makes the map actually load the file I choose

--- src/main.cpp
+++ src/main.cpp
@@ -28,7 +28,7 @@
 std::string readMap(const char *mapName) {

     std::string entry;
-    std::ifstream mapFile("res/map1.txt");
+    std::ifstream mapFile(mapName);

     char line[80];


Able to execute  multiple commands

Able to execute  multiple commands

must test further
command length max 100

--- src/main.cpp
+++ src/main.cpp
@@ -117,32 +117,40 @@
 	    comms.push(array[i]); //pushes commands into queue
 	    i++;
 	}
-	i = 0;
+

 	//char* temp = new char [100];    //mem = 66666
-    while (true)
-    {
-	    //char* temp[100];
-        if(comms.empty())
-        {
-            break;
-        }
-        if ((comms.front() != ";") || (comms.front() != "&&")|| //populate array
-    	    (comms.front() != "||"))
-        {
-            char* temp = new char [100];
-            strcpy(temp, comms.front().c_str());
-            array[i] = temp;
-            comms.pop();
-            i++;
-        }
-        else //comms.front == connector //stop parsing and execvp
-        {
-            connectors.push(comms.front());
-            comms.pop();
-            break;
-    	}
-    }
+	while (true)
+	{
+	    i = 0;
+	    if(comms.empty())
+	    {
+	        break;
+	    }
+
+        while (true)
+        {
+    	    //char* temp[100];
+            if(comms.empty())
+            {
+                break;
+            }
+            if ((comms.front() != ";") || (comms.front() != "&&")|| //populate array
+        	    (comms.front() != "||"))
+            {
+                char* temp = new char [100];
+                strcpy(temp, comms.front().c_str());
+                array[i] = temp;
+                comms.pop();
+                i++;
+            }
+            else //comms.front == connector //stop parsing and execvp
+            {
+                connectors.push(comms.front());
+                comms.pop();
+                break;
+        	}
+        }

     array[i] = '\0';
@@ -171,6 +179,7 @@
         cout << "Work dammit \n";
         execvp(array[0], array);
         cout << "Execute failed \n";
+
         perror("There was an error with the executable or argument list");
     }
     else if (processID > 0)
@@ -183,14 +192,16 @@
     	}
     	if (WIFEXITED(status))
     	{
-    		if(WIFEXITED(status) != 0)
+    		if(WIFEXITED(status) != 0)//command sucess
     		{
-    		    //bool success = false;
+
     		}
     	}

     	cout << "Parent: finished" << endl;
     }
+    break;
+	}

 }
 int main (int argc, char **argv)


Removed bug in main file

Removed bug in main file

Optimisation options were not handling the "all" case where all
optimisations will be enabled.

--- src/main.cpp
+++ src/main.cpp
@@ -74,6 +74,9 @@
     if(optArg.compare("par") == 0) {
         enableOpenMp = true;
     }
+    if(optArg.compare("all") == 0) {
+        enableOpenMp = true;
+    }
 }

 int main(int argc,char * argv[]){
@@ -117,10 +120,11 @@
     }
     if(optind < argc) {
         fname  = argv[optind];
+    } else  {
+        printf("atleast one input file required\n");
     }
     std::string optionStr="";
     initRaptor();
-    fname = argv[1];
     std::string fCopy = fname;
     string s =readDataIntoString(fname);
     VModule *m=NULL;
@@ -135,7 +139,7 @@

     vector<string> vec_cpp = pp.prettyPrint(cntxt.getAllStmt());
     vector<string> vec_hpp = pp.prettyPrint(vc.getHeaderContext().getAllStmt());
-    if(genFile) {
+    if(!genFile) {
         for(int i=0;i<vec_cpp.size();i++){
             std::cout<<vec_cpp[i];
         }


cfund: memory optimization

cfund: memory optimization

--- src/main.cpp
+++ src/main.cpp
@@ -2539,7 +2539,7 @@

     bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const
     {
-        return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == IsSigHFEnabled(Params().GetConsensus(), pindex)) ? VERSIONBITS_TOP_BITS_SIG : VERSIONBITS_TOP_BITS) &&
+        return ((pindex->nVersion & VERSIONBITS_TOP_MASK) == IsSigHFEnabled(Params().GetConsensus(), pindex) ? VERSIONBITS_TOP_BITS_SIG : VERSIONBITS_TOP_BITS) &&
                ((pindex->nVersion >> bit) & 1) != 0 &&
                ((ComputeBlockVersion(pindex->pprev, params) >> bit) & 1) == 0;
     }
@@ -3279,9 +3279,6 @@
     if (!pcfundindex->WriteTipHeight(pindexNew->nHeight))
         AbortNode("Failed to write tip height to proposal db", "");

-    if (!pblocktree->WriteFlag("CFEnabled", IsCommunityFundEnabled(pindexNew->pprev,Params().GetConsensus())))
-        AbortNode("Failed to write CFund-enabled flag", "");
-
     // New best block
     nTimeBestReceived = GetTime();
     mempool.AddTransactionsUpdated(1);
@@ -3477,6 +3474,7 @@

 bool CountVotes(CValidationState& state, CBlockIndex *pindexNew, const CBlock *pblock)
 {
+    CFund::CPaymentRequest prequest; CFund::CProposal proposal;
     if(pindexNew->nHeight % Params().GetConsensus().nVotingPeriod == 0) {
         // We need to reset vote counter and update state of proposals and requests.
         std::vector<CFund::CPaymentRequest> vecPaymentRequest;
@@ -3485,7 +3483,7 @@
         if(pcfundindex->GetPaymentRequestIndex(vecPaymentRequest)){
             for(unsigned int i = 0; i < vecPaymentRequest.size(); i++) {
                 bool fUpdate = false;
-                CFund::CPaymentRequest prequest = vecPaymentRequest[i];
+                prequest = vecPaymentRequest[i];
                 if((prequest.IsRejected() && prequest.fState != CFund::REJECTED) ||
                         (!prequest.IsAccepted() && !prequest.IsRejected())) {
                     if(prequest.IsRejected() && prequest.fState != CFund::REJECTED) {
@@ -3495,10 +3493,9 @@
                     prequest.nVotesYes = 0;
                     fUpdate = true;
                 }
-                CFund::CProposal parent;
-                if(!CFund::FindProposal(prequest.proposalhash, parent))
+                if(!CFund::FindProposal(prequest.proposalhash, proposal))
                     continue;
-                if(parent.fState == CFund::ACCEPTED && prequest.IsAccepted()
+                if(proposal.fState == CFund::ACCEPTED && prequest.IsAccepted()
                         && prequest.fState != CFund::ACCEPTED) {
                     if(prequest.nAmount <= pindexNew->nCFLocked) {
                         pindexNew->nCFLocked -= prequest.nAmount;
@@ -3523,7 +3520,7 @@
         if(pcfundindex->GetProposalIndex(vecProposal)){
             for(unsigned int i = 0; i < vecProposal.size(); i++) {
                 bool fUpdate = false;
-                CFund::CProposal proposal = vecProposal[i];
+                proposal = vecProposal[i];
                 if((proposal.IsExpired(pindexNew->GetMedianTimePast()) && proposal.fState != CFund::EXPIRED) ||
                         (proposal.IsRejected() && proposal.fState != CFund::REJECTED) ||
                         (!proposal.IsAccepted() && !proposal.IsRejected())) {
@@ -3574,11 +3571,11 @@

     std::map<uint256, std::pair<int, int>> vCacheProposalsToUpdate;
     std::map<uint256, std::pair<int, int>> vCachePaymentRequestToUpdate;
+    std::map<uint256, bool> vSeen;

     while(nBlocks > 0 && pindexblock != NULL) {
-        std::map<uint256, bool> vSeen;
+        vSeen.clear();
         for(unsigned int i = 0; i < pindexblock->vProposalVotes.size(); i++) {
-            CFund::CProposal proposal;
             if(!CFund::FindProposal(pindexblock->vProposalVotes[i].first, proposal))
                 continue;
             if(proposal.CanVote() && vSeen.count(pindexblock->vProposalVotes[i].first) == 0) {
@@ -3592,15 +3589,15 @@
             }
         }
         for(unsigned int i = 0; i < pindexblock->vPaymentRequestVotes.size(); i++) {
-            CFund::CPaymentRequest prequest; CFund::CProposal parent;
+
             if(!CFund::FindPaymentRequest(pindexblock->vPaymentRequestVotes[i].first, prequest))
                 continue;
-            if(!CFund::FindProposal(prequest.proposalhash, parent))
+            if(!CFund::FindProposal(prequest.proposalhash, proposal))
                 continue;
-            CBlockIndex* pindexblockparent = mapBlockIndex[parent.blockhash];
+            CBlockIndex* pindexblockparent = mapBlockIndex[proposal.blockhash];
             if(pindexblockparent == NULL)
                 continue;
-            if(parent.CanRequestPayments() && prequest.CanVote()
+            if(proposal.CanRequestPayments() && prequest.CanVote()
                     && vSeen.count(pindexblock->vPaymentRequestVotes[i].first) == 0
                     && pindexblock->nHeight - pindexblockparent->nHeight > Params().GetConsensus().nCommunityFundMinAge) {
                 if(vCachePaymentRequestToUpdate.count(pindexblock->vPaymentRequestVotes[i].first) == 0)
@@ -3620,7 +3617,6 @@
     std::vector<std::pair<uint256, CFund::CProposal>> vecProposalsToUpdate;
     std::vector<std::pair<uint256, CFund::CPaymentRequest>> vecPaymentRequestsToUpdate;
     for(it = vCacheProposalsToUpdate.begin(); it != vCacheProposalsToUpdate.end(); it++) {
-        CFund::CProposal proposal;
         if(!CFund::FindProposal(it->first, proposal))
             continue;
         proposal.nVotesYes = it->second.first;
@@ -3628,7 +3624,6 @@
         vecProposalsToUpdate.push_back(make_pair(proposal.hash, proposal));
     }
     for(it = vCachePaymentRequestToUpdate.begin(); it != vCachePaymentRequestToUpdate.end(); it++) {
-        CFund::CPaymentRequest prequest;
         if(!CFund::FindPaymentRequest(it->first, prequest))
             continue;
         prequest.nVotesYes = it->second.first;


Bugfix: fForRelay should be false when deciding required fee to include in blocks

During the rushed transition from 0.01 BTC to 0.0005 BTC fees, we took the
approach of dropping the relay and block-inclusion fee to 0.0005 BTC
immediately, and only delayed adjusting the sending fee for the next release.
Afterward, the relay fee was lowered to 0.0001 BTC to avoid having the same
problem in the future. However, the block inclusion code was left setting
fForRelay to true! This fixes that, so the lower 0.0001 BTC allowance is (as
intended) only permitted for real relaying.

--- src/main.cpp
+++ src/main.cpp
@@ -2757,7 +2757,7 @@

             // Transaction fee required depends on block size
             bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
-            int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, true);
+            int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree);

             // Connecting shouldn't fail due to dependency on other memory pool transactions
             // because we're already processing them in order of dependency


Set up initial distribution

Set up initial distribution

Maximum coins = 20 000 000

--- src/main.cpp
+++ src/main.cpp
@@ -1136,8 +1136,9 @@
 mpq static GetInitialDistributionAmount(int nHeight)
 {
     mpq nSubsidy = 0;
-    if ( nHeight < EQ_HEIGHT )
-        nSubsidy = TITHE_AMOUNT + (EQ_HEIGHT-nHeight) * INITIAL_SUBSIDY / EQ_HEIGHT;
+     mpq nSubsidy = 4000 * COIN;
+    // Subsidy is cut in half every 2500 blocks, which will occur approximately every 17.36 days
+    nSubsidy >>= (nHeight / 2500);
     return nSubsidy;
 }


foret_rand

--- src/main.cpp
+++ src/main.cpp
@@ -1,6 +1,7 @@
 #include <irrlicht.h>
 #include "events.h"
 #include "gui_game.h"
+

 using namespace irr;

@@ -15,7 +16,7 @@
 is::ITriangleSelector* createMountain(int nbMountains, is::IAnimatedMeshSceneNode *node, is::IAnimatedMesh *mesh, is::ISceneManager *smgr, std::vector<iv::ITexture*> textures, EventReceiver receiver);

 const int ID = 40;
-const int cpt = 0;
+

 int main()
 {
@@ -97,18 +98,21 @@
     is::IAnimatedMeshSceneNode *node_tree;
     int Nl = 7;
     int Nk = 7;
+    int pos_x;
+    int pos_y;

     for (int l=0; l<Nl; l++)
     {
 	for (int k=0; k<Nk; k++)
-	{
+	{
+	    pos_x = rand()%Nl + 8*l;
+	    pos_y = rand()%Nk + 5*k;
+
 	    node_tree = smgr->addAnimatedMeshSceneNode(mesh_tree,nullptr, l+k);
 	    node_tree->setMaterialFlag(irr::video::EMF_LIGHTING, false);
-	    node_tree->setPosition(core::vector3df(10+4*l, 4.3, 60+4*k));//30+4*l, 4.3, 5+4*l));
+	    node_tree->setPosition(core::vector3df(pos_x, 4.3,pos_y));//30+4*l, 4.3, 5+4*l));
 	    node_tree->setScale(core::vector3df(1.5,1.5,1.5));
 	    receiver.set_node(node_tree);
-
-	    //node_tree->setDebugDataVisible(is::EDS_NORMALS);

 	    //selector sur l'arbre
 	    is::ITriangleSelector *selector = smgr->createTriangleSelector(mesh_tree,node_tree);
@@ -125,7 +129,7 @@
     is::IAnimatedMeshSceneNode *node_santaclaus;
     node_santaclaus = smgr->addAnimatedMeshSceneNode(mesh_santaclaus);
     node_santaclaus->setMaterialFlag(irr::video::EMF_LIGHTING, false);
-    node_santaclaus->setPosition(core::vector3df(20, 2, 30));
+    node_santaclaus->setPosition(core::vector3df(20,2,60)); //20, 2, 30));
     textures.push_back(driver->getTexture("data/Santa.png"));
     node_santaclaus->setMaterialTexture(0, textures.back());
     node_santaclaus->setScale(core::vector3df(0.5,0.5,0.5));
@@ -183,7 +187,6 @@
 	  if (selected_scene_node)
 	  {
 	    selected_scene_node->setVisible(false);
-	    cpt ++;
 	  }

 	}


Added locks on the setpwalletRegistered functions in main.cpp and added an UnregisterAllWallets function.

Conflicts:
	src/main.cpp

Conflicts:

	src/main.cpp

--- src/main.cpp
+++ src/main.cpp
@@ -101,7 +101,13 @@
         setpwalletRegistered.erase(pwalletIn);
     }
 }
-
+
+void UnregisterAllWallets()
+{
+    LOCK(cs_setpwalletRegistered);
+    setpwalletRegistered.clear();
+}
+
 // check whether the passed transaction is from us
 bool static IsFromMe(CTransaction& tx)
 {
@@ -114,6 +120,7 @@
 // get the wallet transaction with the given hash (if it exists)
 bool static GetTransaction(const uint256& hashTx, CWalletTx& wtx)
 {
+    LOCK(cs_setpwalletRegistered);
     BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
         if (pwallet->GetTransaction(hashTx,wtx))
             return true;
@@ -123,6 +130,7 @@
 // erases transaction with the given hash from all wallets
 void static EraseFromWallets(uint256 hash)
 {
+    LOCK(cs_setpwalletRegistered);
     BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
         pwallet->EraseFromWallet(hash);
 }
@@ -130,6 +138,8 @@
 // make sure all wallets know about the given transaction, in the given block
 void SyncWithWallets(const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fConnect)
 {
+    LOCK(cs_setpwalletRegistered);
+
     if (!fConnect)
     {
         // ppcoin: wallets need to refund inputs when disconnecting coinstake
@@ -149,6 +159,7 @@
 // notify wallets about a new best chain
 void static SetBestChain(const CBlockLocator& loc)
 {
+    LOCK(cs_setpwalletRegistered);
     BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
         pwallet->SetBestChain(loc);
 }
@@ -156,6 +167,7 @@
 // notify wallets about an updated transaction
 void static UpdatedTransaction(const uint256& hashTx)
 {
+    LOCK(cs_setpwalletRegistered);
     BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
         pwallet->UpdatedTransaction(hashTx);
 }
@@ -163,6 +175,7 @@
 // dump all wallets
 void static PrintWallets(const CBlock& block)
 {
+    LOCK(cs_setpwalletRegistered);
     BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
         pwallet->PrintWallet(block);
 }
@@ -170,6 +183,7 @@
 // notify wallets about an incoming inventory (for request counts)
 void static Inventory(const uint256& hash)
 {
+    LOCK(cs_setpwalletRegistered);
     BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
         pwallet->Inventory(hash);
 }
@@ -177,6 +191,7 @@
 // ask wallets to resend their transactions
 void ResendWalletTransactions(bool fForce)
 {
+    LOCK(cs_setpwalletRegistered);
     BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
         pwallet->ResendWalletTransactions(fForce);
 }


updated min value

updated min value

--- src/main.cpp
+++ src/main.cpp
@@ -49,7 +49,6 @@
 bool fBenchmark = false;
 bool fTxIndex = false;
 unsigned int nCoinCacheSize = 5000;
-unsigned int nTargetMinLength = 6;     // minimum chain length target

 /** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */
 int64 CTransaction::nMinTxFee = 100000;
@@ -1075,8 +1074,6 @@
     nMint = 0;
     static uint64 nMintLimit = 50 * COIN;
     CBigNum bnMint = nMintLimit;
-    if (TargetGetLength(nBits) < nTargetMinLength)
-        return error("TargetGetMint() : length below minimum required, nBits=%08x", nBits);
     bnMint = (bnMint << nFractionalBits) / nBits;
     bnMint = (bnMint << nFractionalBits) / nBits;
     bnMint = (bnMint / CENT) * CENT;  // mint value rounded to cent


changes

changes

--- src/main.cpp
+++ src/main.cpp
@@ -2045,10 +2045,10 @@
         printf("%s\n", block.GetHash().ToString().c_str());
         printf("%s\n", hashGenesisBlock.ToString().c_str());
         printf("%s\n", block.hashMerkleRoot.ToString().c_str());
-        assert(block.hashMerkleRoot == uint256("0x5a2e19825b4162f68602039040f1e05d9f924ff00a3aff7327ca6abd6f3279bc"));
+        assert(block.hashMerkleRoot == uint256("cb0a61a1febe181a62b9300c88b00d2801d1d7c475a94430f2a6c64fc5397d54"));

         // If genesis block hash does not match, then generate new genesis hash.
-        if (false && block.GetHash() != hashGenesisBlock)
+        if (true && block.GetHash() != hashGenesisBlock)
         {
             printf("Searching for genesis block...\n");
             // This will figure out a valid hash and Nonce if you're


Added intro to the terminal gui and key press recognition.

--- src/main.cpp
+++ src/main.cpp
@@ -3,7 +3,6 @@
 //Purpose: This is a project to create a working chess engine and gui using C++.
 //File: This is the main file.
 #include <iostream>
-#include <memory>
 #include "board.h"
 #include "pawn.h"
 #include "knight.h"
@@ -11,17 +10,15 @@
 #include "coord.h"
 #include "BearLibTerminal.h"

-#define sizeY 8
-#define sizeX 8
-
 int main()
 {
 	board Chessboard;
-	board::Square **tile = new board::Square*[sizeY];
+	// Do these need to be on the heap?
+	board::Square **tile = new board::Square*[board::sizeY];

-	for (int index = 0; index < sizeY; ++index)
+	for (int index = 0; index < board::sizeY; ++index)
 	{
-		tile[index] = new board::Square[sizeX];
+		tile[index] = new board::Square[board::sizeX];
 	}

 	Chessboard.initializeBoard(tile);
@@ -57,26 +54,64 @@
 	//Chessboard.placePiece("Pawn1", testPawn->getPosition().x, testPawn->getPosition().y, tile);
 	//Chessboard.placePiece("Knight1", testPawn->getPosition().x, testPawn->getPosition().y, tile);

+
+	// Open the terminal. Since no terminal_set() method is called,
+	// the terminal will use default settings.
+	terminal_open();
+
+	// Print intro text.
+	terminal_print(1, 1, "Chess Engine");
+	terminal_print(4, 2, "by Julian Yi, Sean Brock, and Simon Kim");
+	terminal_print(1, 4, "Press Enter to start...");
+	terminal_refresh();
+
+	bool running = true;
+	while (running) {
+		// Check for input. termnial_read() is blocking, meaning the
+		// program will wait until it reads a key press.
+		auto key = terminal_read();
+
+		// Reset the terminal to blank state.
+		terminal_clear();
+
+		// Print instructions.
+		terminal_print(1, 1, "Press Enter to start...");
+
+		// Handle key presses.
+		switch (key) {
+			case TK_CLOSE:
+				running = false;
+				break;
+			case TK_ESCAPE:
+				running = false;
+				break;
+			case TK_ENTER:
+				terminal_print(1, 2, "Simon is king; Kylee is queen.");
+				break;
+			default:
+				terminal_print(1, 2, "The key pressed has no function.");
+				break;
+		}
+
+		// Commit the buffer and draw it.
+		terminal_refresh();
+
+	}
+
+	// We're done here.
+	terminal_close();
+
+	// Do we need to delete pointers if we are exiting?
+	/*
 	std::cout << "pause here" << std::endl;

-	for (int index = 0; index < sizeY; ++index)
+	for (int index = 0; index < board::sizeY; ++index)
 	{
 		delete[] tile[index];
 	}

 	delete[] tile;
-
-	terminal_open();
-
-	// Printing text
-    terminal_print(1, 1, "Hello, world!");
-    terminal_refresh();
-
-    // Wait until user close the window
-    while (terminal_read() != TK_CLOSE);
-
-    terminal_close();
-
+	*/
 	return 0;
 }


Latest binary of Apache Arrow actually has test-utils.h in arrow/compute/

--- tree/dataframe/test/datasource_arrow.cxx
+++ tree/dataframe/test/datasource_arrow.cxx
@@ -11,7 +11,7 @@
 #include <arrow/memory_pool.h>
 #include <arrow/record_batch.h>
 #include <arrow/table.h>
-#include <arrow/test-util.h>
+#include <arrow/compute/test-util.h>
 #if defined(__GNUC__)
 #pragma GCC diagnostic pop
 #endif


[TTreeReader][ROOT-9757] Return the correct branch

- When a leaf name contains the name of its parent branch on it and a
  branch with the desired name has already been found, the priority
  given by SearchBranchWithCompositeName should not be considered.

--- tree/treeplayer/src/TTreeReaderValue.cxx
+++ tree/treeplayer/src/TTreeReaderValue.cxx
@@ -402,12 +402,24 @@
    TBranch *branch = nullptr;
    // If the branch name contains at least a dot, we analyse it in detail and
    // we give priority to the branch identified over the one which is found
-   // with the TTree::GetBranch method. This allow to correctly pick the desired
+   // with the TTree::GetBranch method. This allows to correctly pick the desired
    // branch in cases where a TTree has two branches, one called for example
    // "w.v.a" and another one called "v.a".
    // This behaviour is described in ROOT-9312.
    if (fBranchName.Contains(".")) {
       branch = SearchBranchWithCompositeName(myLeaf, branchActualType, errMsg);
+      // In rare cases where leaves contain the name of the branch as part of their
+      // name and a dot in the branch name (such as: branch "b." and leaf "b.a")
+      // the previous method may return the branch name ("b.") rather than the
+      // leaf name ("b.a") as we expect.
+      // For these cases, we do not have to give priority to the previously
+      // identified branch since we are in a different situation.
+      // This behaviour is described in ROOT-9757.
+      if (branch && branch->IsA() == TBranchElement::Class() && branchFromFullName){
+        branch = branchFromFullName;
+        fStaticClassOffsets = {};
+        fHaveStaticClassOffsets = 0;
+      }
    }

    if (!branch) {
@@ -625,4 +637,3 @@

    return 0;
 }
-


Fixes for coverity issues 51895, 51894 and 51893

--- tree/treeplayer/src/TTreeReaderValue.cxx
+++ tree/treeplayer/src/TTreeReaderValue.cxx
@@ -87,7 +87,24 @@

       if (newChainOffset != fTreeLastOffset){
          fTreeLastOffset = newChainOffset;
-         fLeaf = fTreeReader->GetTree()->GetBranch(fBranchName)->GetLeaf(fLeafName);
+
+         TTree *myTree = fTreeReader->GetTree();
+
+         if (!myTree) {
+            fReadStatus = kReadError;
+            Error("GetLeaf()", "Unable to get the tree from the TTreeReader");
+            return 0;
+         }
+
+         TBranch *myBranch = myTree->GetBranch(fBranchName);
+
+         if (!myBranch) {
+            fReadStatus = kReadError;
+            Error("GetLeaf()", "Unable to get the branch from the tree");
+            return 0;
+         }
+
+         fLeaf = myBranch->GetLeaf(fLeafName);
       }
       return fLeaf;
    }
@@ -102,13 +119,14 @@
    if (ProxyRead() != kReadSuccess) return 0;

    if (fLeafName.Length() > 0){
-      Long64_t newChainOffset = fTreeReader->GetTree()->GetChainOffset();
-
-      if (newChainOffset != fTreeLastOffset){
-         fTreeLastOffset = newChainOffset;
-         fLeaf = fTreeReader->GetTree()->GetBranch(fBranchName)->GetLeaf(fLeafName);
-      }
-      return fLeaf->GetValuePointer();
+      if (GetLeaf()){
+         return fLeaf->GetValuePointer();
+      }
+      else {
+         fReadStatus = kReadError;
+         Error("GetAddress()", "Unable to get the leaf");
+         return 0;
+      }
    }
    return fProxy ? (Byte_t*)fProxy->GetWhere() : 0;
 }


Added "Reset Controls" Feature under the Main-Menu Options->Controls

git-svn-id: f2a8673b7e889ad8d17934c9305340c613bca262@102 4df4b0f3-56ce-47cb-b001-ed939b7d65a6

--- src/menu.cpp
+++ src/menu.cpp
@@ -1198,7 +1198,7 @@
 	// Prepare the Games Menu
 	ControlsMenu = new CDialog();

-	ControlsMenu->setDimensions(1,3,38,20);
+	ControlsMenu->setDimensions(1,2,38,21);

 	g_pInput->getEventName(IC_LEFT, 0, buf2);
 	sprintf(buf,"P1 Left:   %s",buf2);
@@ -1250,6 +1250,7 @@
 	sprintf(buf,"P2 Status: %s",buf2);
 	ControlsMenu->addOptionText(buf);
 	ControlsMenu->addSeparator();
+	ControlsMenu->addOptionText("Reset Controls");
 	ControlsMenu->addOptionText("Return");

 	ControlsMenu->animateDialogBox(true);
@@ -1340,6 +1341,13 @@
 				strcat(buf,buf2);
 				ControlsMenu->setOptionText(selection,buf);
 			}
+			else if(selection == MAX_COMMANDS*2+1)
+			{
+				// Reset Controls here!
+				g_pInput->resetControls();
+				g_pInput->saveControlconfig();
+				break;
+			}
 			else
 			{
 				g_pInput->saveControlconfig();


Removing volume normalization from tally values.

--- src/mesh.cpp
+++ src/mesh.cpp
@@ -1686,7 +1686,7 @@
     moab::EntityHandle last_r_tet = get_tet(last_r + u * track_len * 0.5);
     if (last_r_tet) {
       bins.push_back(get_bin_from_ent_handle(last_r_tet));
-      lengths.push_back(1.0 / tet_volume(last_r_tet));
+      lengths.push_back(1.0);
     }
     return;
   }
@@ -1704,7 +1704,7 @@
   // if there are no other hits, there is only one segment to tally
   if (hits.size() == 0 && tet) {
     bins.push_back(get_bin_from_ent_handle(tet));
-    lengths.push_back(1.0 / tet_volume(tet));
+    lengths.push_back(1.0);
     return;
   }

@@ -1713,7 +1713,7 @@
     // score in this tet if one was found
     if (tet) {
       bins.push_back(get_bin_from_ent_handle(tet));
-      lengths.push_back((hit.first - last_dist) / (track_len * tet_volume(tet)));
+      lengths.push_back((hit.first - last_dist) / track_len);
     } else {
       // if in the loop, we should always find a tet
       fatal_error("No tet found for location between trianle hits");
@@ -1740,7 +1740,7 @@
     tet = get_tet(last_r + u * (track_len + hits.back().first) / 2.0);
     if (tet) {
       bins.push_back(get_bin_from_ent_handle(tet));
-      lengths.push_back((track_len - hits.back().first) / (track_len* tet_volume(tet)));
+      lengths.push_back((track_len - hits.back().first) / track_len);
     }
   }

@@ -1753,7 +1753,7 @@
   //   moab::EntityHandle last_r_tet =get_tet((r0 + r1) * 0.5);
   //   if (last_r_tet) {
   //     bins.push_back(get_bin_from_ent_handle(last_r_tet));
-  //     lengths.push_back(1.0 / tet_volume(last_r_tet));
+  //     lengths.push_back(1.0);
   //   }
   //   return;
   // }
@@ -1772,7 +1772,7 @@
   //     continue;
   //   }
   //   int bin = get_bin_from_ent_handle(tet);
-  //   double tally_val = (hit.first - prev_int_dist) / (track_len * tet_volume(tet));
+  //   double tally_val = (hit.first - prev_int_dist) / track_len);
   //   if (tally_val < 0.0) {
   //     fatal_error("Negative score applied to tally");
   //   }
@@ -1787,7 +1787,7 @@
   //   tet = get_tet(last_r + u * (track_len + hits.back().first) / 2.0);
   //   if (tet) {
   //     bins.push_back(get_bin_from_ent_handle(tet));
-  //     double tally_val = (track_len - hits.back().first) / (track_len * tet_volume(tet));
+  //     double tally_val = (track_len - hits.back().first) / track_len);
   //     lengths.push_back(tally_val);
   //   }
   // }


node: fix operator= macro bug

node: fix operator= macro bug

--- src/node.cpp
+++ src/node.cpp
@@ -43,11 +43,23 @@
 }

-#define TYPE_FUNC_ASSIGN(typ, short_typ) \
+#define TYPE_FUNC_ASSIGN(typ, short_typ, e_typ) \
 node& node::operator=(const typ o) \
 { \
   _release_contents(); \
+  m_type = (int)type::e_typ; \
   m_##short_typ = o; \
+  return *this; \
+}
+
+
+/* Sadly, string is special-cased because of its COW semantics. */
+#define TYPE_FUNC_ASSIGN_STR(typ) \
+node& node::operator=(const typ o) \
+{ \
+  _release_contents(); \
+  m_type = (int)type::U8STR; \
+  new (&m_str) std::string(o); \
   return *this; \
 }

@@ -287,13 +299,13 @@
 /* TODO: how should we handle uint64_t? */

-TYPE_FUNC_ASSIGN(bool, boo)
-TYPE_FUNC_ASSIGN(double, dbl)
-TYPE_FUNC_ASSIGN(int, int)
-TYPE_FUNC_ASSIGN(unsigned int, int)
-TYPE_FUNC_ASSIGN(int64_t, int)
-TYPE_FUNC_ASSIGN(char *, str)
-TYPE_FUNC_ASSIGN(std::string &, str)
+TYPE_FUNC_ASSIGN(bool, boo, BOOL)
+TYPE_FUNC_ASSIGN(double, dbl, DOUBLE)
+TYPE_FUNC_ASSIGN(int, int, INT64)
+TYPE_FUNC_ASSIGN(unsigned int, int, INT64)
+TYPE_FUNC_ASSIGN(int64_t, int, INT64)
+TYPE_FUNC_ASSIGN_STR(char *)
+TYPE_FUNC_ASSIGN_STR(std::string &)
 /* TODO: how should we handle uint64_t? */


Parsing Options from Command Line is Finished

--- src/pill.cpp
+++ src/pill.cpp
@@ -29,46 +29,45 @@
 using namespace std;

 int main(int argc, char *argv[]) {
-	// the options:
-	// 1.) search string
-	// 2.) editor
-	// 3.) root search path
-	// 4.) role/extension array
-	// 5.) maximum results
-	const unsigned int MAX_OPTIONS = 5;
-	string options[MAX_OPTIONS];
+	// the default options
+	string query = "";
+	string editor = "vim";
+	string path = "./";
+	string role = "";
+	string extensions[] = {"*"};
+	unsigned int results_cap = 25;

-	for (int i = 0; i < MAX_OPTIONS; i++) {
-		options[i] = "";
-	}
-
+	// get the options from the command line
 	for (int i = 1; i < argc; i++) {
 		if (!strcmp(argv[i], "--editor")) {
 			if (i != (argc - 1)) {
-				options[1] = argv[i + 1];
+				editor = argv[i + 1];
 				i++;
 			}
 		} else if (!strcmp(argv[i], "--path")) {
 			if (i != (argc - 1)) {
-				options[2] = argv[i + 1];
+				path = argv[i + 1];
 				i++;
 			}
 		} else if (!strcmp(argv[i], "--role")) {
 			if (i != (argc - 1)) {
-				options[3] = argv[i + 1];
+				role = argv[i + 1];
 				i++;
 			}
 		} else if (!strcmp(argv[i], "--max")) {
 			if (i != (argc - 1)) {
-				options[4] = argv[i + 1];
+				results_cap = atoi(argv[i + 1]);
 				i++;
 			}
 		} else if (i == 1) {
-			options[0] = argv[i];
+			query = argv[i];
 		}
 	}

-	// 2.) default any options not set or invalid (empty strings)
+	if (!query.compare("")) {
+		cout << "You must provide a search string as the first argument to pill." << endl;
+		return 0;
+	}

 	// 3.) grab the options from external files


removing redundant initialization of calibration validator

--- src/r200.cpp
+++ src/r200.cpp
@@ -10,8 +10,7 @@
 namespace rsimpl
 {
     r200_camera::r200_camera(std::shared_ptr<uvc::device> device, const static_device_info & info)
-        : ds_device(device, info,
-        calibration_validator([](rs_stream, rs_stream){return true; }, [](rs_stream){return true; }))
+        : ds_device(device, info, calibration_validator())
     {
     }


Compare against empty instead of size

Compare against empty instead of size

Contributes to CURA-7115

--- src/skin.cpp
+++ src/skin.cpp
@@ -630,11 +630,11 @@

         for (SliceLayerPart& part : layer.parts)
         {
-            assert(part.infill_area_per_combine_per_density.size() == 0 && "infill_area_per_combine_per_density is supposed to be uninitialized");
+            assert((part.infill_area_per_combine_per_density.empty() && "infill_area_per_combine_per_density is supposed to be uninitialized"));

             const Polygons& infill_area = part.getOwnInfillArea();

-            if (infill_area.size() == 0 || layer_idx < min_layer || layer_idx > max_layer)
+            if (infill_area.empty() || layer_idx < min_layer || layer_idx > max_layer)
             { // initialize infill_area_per_combine_per_density empty
                 part.infill_area_per_combine_per_density.emplace_back(); // create a new infill_area_per_combine
                 part.infill_area_per_combine_per_density.back().emplace_back(); // put empty infill area in the newly constructed infill_area_per_combine
@@ -666,7 +666,7 @@
                     }
                     less_dense_infill = less_dense_infill.intersection(relevent_upper_polygons);
                 }
-                if (less_dense_infill.size() == 0)
+                if (less_dense_infill.empty())
                 {
                     break;
                 }
@@ -680,7 +680,7 @@
             std::vector<Polygons>& infill_area_per_combine_current_density = part.infill_area_per_combine_per_density.back();
             infill_area_per_combine_current_density.push_back(infill_area);
             part.infill_area_own = nullptr; // clear infill_area_own, it's not needed any more.
-            assert(part.infill_area_per_combine_per_density.size() != 0 && "infill_area_per_combine_per_density is now initialized");
+            assert(!part.infill_area_per_combine_per_density.empty() && "infill_area_per_combine_per_density is now initialized");
         }
     }
 }


Fix typo. downSkinCount -> upSkinCount

Fix typo. downSkinCount -> upSkinCount

This typo causes flaky crash when downSkinCount < upSkinCount.

--- src/skin.cpp
+++ src/skin.cpp
@@ -77,7 +77,7 @@
                 downskin = downskin.difference(not_air); // skin overlaps with the walls
             }

-            if (layer_nr < static_cast<int>(storage.layers.size()) - downSkinCount && upSkinCount > 0)
+            if (layer_nr < static_cast<int>(storage.layers.size()) - upSkinCount && upSkinCount > 0)
             {
                 Polygons not_air = getInsidePolygons(storage.layers[layer_nr + 1]);
                 for (int upskin_layer_nr = layer_nr + 2; upskin_layer_nr < layer_nr + upSkinCount + 1; upskin_layer_nr++)


Add some logging that might help diagnose BasicSync_ResumeSyncFromSessionAfterNonclashingLocalAndRemoteChanges failures on Mac (possibly due to timing or clock inconsistencies)

--- src/sync.cpp
+++ src/sync.cpp
@@ -2126,7 +2126,7 @@

         if (notification.timestamp > dsmin)
         {
-            LOG_verbose << "Scanning postponed. Modification too recent";
+            LOG_verbose << syncname << "Scanning postponed. Modification too recent: " << notification.timestamp << " (ds) vs now " << Waiter::ds << " at " << notification.path;
             dirnotify->notifyq[q].unpopFront(notification);
             return notification.timestamp - dsmin;
         }


Improve readability

Improve readability

--- src/sync.cpp
+++ src/sync.cpp
@@ -2992,7 +2992,8 @@
         }

         // Record this slot-time pair.
-        slotTimes.emplace_back(suffix - 0x30, fileAccess->mtime);
+        unsigned int slot = suffix - 0x30; // convert char to int
+        slotTimes.emplace_back(slot, fileAccess->mtime);
     }

     // Sort the list of slot-time pairs.
@@ -3347,4 +3348,3 @@
 } // namespace

 #endif
-


Use CancelSynchronousIo on Windows

Use CancelSynchronousIo on Windows

--- src/test.cpp
+++ src/test.cpp
@@ -160,9 +160,10 @@
   if (!read_done) {
 #ifndef _WIN32
     pthread_kill(thread.native_handle(), SIGPIPE);
+#elif _MSC_VER
+    CancelSynchronousIo(thread.native_handle());
 #else
     (void)thread;
-    //CancelSynchronousIo(thread.native_handle());
 #endif
   }
 }
@@ -191,8 +192,12 @@
   std::thread thread2(
       [&]() { write_succeeded = client(buf, con, write_done, lock); });
   auto interrupter = std::thread{[&]() {
+#ifndef _WIN32
     struct timespec q = {1, 0};
     nanosleep(&q, nullptr);
+#else
+    Sleep(1000);
+#endif
     interrupt_thread(lock2, read_done, thread);
     interrupt_thread(lock, write_done, thread2);
   }};


Changed box to object

Changed box to object

--- src/test.cpp
+++ src/test.cpp
@@ -10,7 +10,7 @@
 using namespace chrono;

 // Global scop box
-shared_ptr<mesh> box;
+shared_ptr<mesh> object;
 // Keep track of current mode
 int MODE = 0;

@@ -51,22 +51,22 @@
 {
 	// Move the quad when arrow keys are pressed
 	if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_RIGHT)) {
-		box->trans.translate(vec3(10.0, 0.0, 0.0) * deltaTime);
+		object->trans.translate(vec3(10.0, 0.0, 0.0) * deltaTime);
 	}
 	if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_LEFT)) {
-		box->trans.translate(vec3(-10.0, 0.0, 0.0) * deltaTime);
+		object->trans.translate(vec3(-10.0, 0.0, 0.0) * deltaTime);
 	}
 	if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_UP)) {
-		box->trans.translate(vec3(0.0, 0.0, -10.0) * deltaTime);
+		object->trans.translate(vec3(0.0, 0.0, -10.0) * deltaTime);
 	}
 	if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_DOWN)) {
-		box->trans.translate(vec3(0.0, 0.0, 10.0) * deltaTime);
+		object->trans.translate(vec3(0.0, 0.0, 10.0) * deltaTime);
 	}
 	if (glfwGetKey(renderer::get_instance().get_window(), 'W')) {
-		box->trans.translate(vec3(0.0, 10.0, 0.0) * deltaTime);
+		object->trans.translate(vec3(0.0, 10.0, 0.0) * deltaTime);
 	}
 	if (glfwGetKey(renderer::get_instance().get_window(), 'S')) {
-		box->trans.translate(vec3(0.0, -10.0, 0.0) * deltaTime);
+		object->trans.translate(vec3(0.0, -10.0, 0.0) * deltaTime);
 	}
 } // userTranslation()

@@ -79,22 +79,22 @@
 void userRotation(float deltaTime) {

   if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_UP)) {
-	  box->trans.rotate(vec3(-pi<float>(), 0.0, 0.0f) * deltaTime);
+	  object->trans.rotate(vec3(-pi<float>(), 0.0, 0.0f) * deltaTime);
   }
   if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_DOWN)) {
-	  box->trans.rotate(vec3(pi<float>(), 0.0, 0.0f) * deltaTime);
+	  object->trans.rotate(vec3(pi<float>(), 0.0, 0.0f) * deltaTime);
   }
   if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_RIGHT)) {
-	  box->trans.rotate(vec3(0.0, -pi<float>(), 0.0f) * deltaTime);
+	  object->trans.rotate(vec3(0.0, -pi<float>(), 0.0f) * deltaTime);
   }
   if (glfwGetKey(renderer::get_instance().get_window(), GLFW_KEY_LEFT)) {
-	  box->trans.rotate(vec3(0.0, pi<float>(), 0.0f) * deltaTime);
+	  object->trans.rotate(vec3(0.0, pi<float>(), 0.0f) * deltaTime);
   }
   if (glfwGetKey(renderer::get_instance().get_window(), 'W')) {
-	  box->trans.rotate(vec3(0.0, 0.0, pi<float>()) * deltaTime);
+	  object->trans.rotate(vec3(0.0, 0.0, pi<float>()) * deltaTime);
   }
   if (glfwGetKey(renderer::get_instance().get_window(), 'S')) {
-	  box->trans.rotate(vec3(0.0, 0.0, -pi<float>()) * deltaTime);
+	  object->trans.rotate(vec3(0.0, 0.0, -pi<float>()) * deltaTime);
   }

 } // userRotation
@@ -155,8 +155,8 @@
 	glfwSetKeyCallback(renderer::get_instance().get_window(), key_callback);

 	// Create box
-	box = make_shared<mesh>();
-	box->geom = geometry_builder::create_box();
+	object = make_shared<mesh>();
+	object->geom = geometry_builder::create_box();

 	// Load in effect.  Start with shaders
@@ -168,10 +168,10 @@
 	}

 	// Create material for box
-	box->mat = make_shared<material>();
-	box->mat->effect = eff;
-	box->mat->set_uniform_value("colour", vec4(0.0, 1.0, 0.0, 1.0));
-	box->mat->set_uniform_value("hue", vec4(1.0, 0.0, 0.0, 1.0));
+	object->mat = make_shared<material>();
+	object->mat->effect = eff;
+	object->mat->set_uniform_value("colour", vec4(0.0, 1.0, 0.0, 1.0));
+	object->mat->set_uniform_value("hue", vec4(1.0, 0.0, 0.0, 1.0));

 	// Monitor the elapsed time per frame
 	auto currentTimeStamp = system_clock::now();
@@ -195,7 +195,7 @@
 		if (renderer::get_instance().begin_render())
 		{
 			// Render Cube
-			renderer::get_instance().render(box);
+			renderer::get_instance().render(object);

 			// End the render
 			renderer::get_instance().end_render();


Added basic edge detection

Added basic edge detection

Hacked in basic edge detection in to the program to complete exercise 6.4.1

--- src/test.cpp
+++ src/test.cpp
@@ -37,17 +37,28 @@

   // Move the quad when arrow keys are pressed
   if (glfwGetKey(window, GLFW_KEY_RIGHT)){
-    position += glm::vec3(1.0f, 0.0f, 0.0f) * float(deltaTime);
+    if (position.x < 0.5) {
+      position += glm::vec3(1.0f, 0.0f, 0.0f) * float(deltaTime);
+    }
   }
   if (glfwGetKey(window, GLFW_KEY_LEFT)){
-    position -= glm::vec3(1.0f, 0.0f, 0.0f) * float(deltaTime);
+    if (position.x > -0.5) {
+      position -= glm::vec3(1.0f, 0.0f, 0.0f) * float(deltaTime);
+    }
   }
   if (glfwGetKey(window, GLFW_KEY_UP)){
-    position += glm::vec3(0.0f, 1.0f, 0.0f) * float(deltaTime);
+    if (position.y < 0.5) {
+      position += glm::vec3(0.0f, 1.0f, 0.0f) * float(deltaTime);
+    }
   }
   if (glfwGetKey(window, GLFW_KEY_DOWN)){
-    position -= glm::vec3(0.0f, 1.0f, 0.0f) * float(deltaTime);
+    if (position.y > -0.5) {
+      position -= glm::vec3(0.0f, 1.0f, 0.0f) * float(deltaTime);
+    }
   }
+
+
+
 } // update

 //renders the application


Do not print status information

Do not print status information

--- src/test.cpp
+++ src/test.cpp
@@ -111,7 +111,8 @@

 bool test()
 {
-  srand((unsigned) time(0));
+  set_print_status(false);
+  srand(static_cast<unsigned>(time(0)));
   try
   {
     test_phi_thread_safety(100);


Changed LevelDB cursors to use scoped pointers to ensure destruction when going out of scope.

This corrects a bug where an exception thrown reading from the database causes the cursor to
be left open, which causes an assertion error to occur when the database is deleted (around
line 938 of init.cpp).

--- src/txdb.cpp
+++ src/txdb.cpp
@@ -103,7 +103,7 @@
 }

 bool CCoinsViewDB::GetStats(CCoinsStats &stats) {
-    leveldb::Iterator *pcursor = db.NewIterator();
+    boost::scoped_ptr<leveldb::Iterator> pcursor(db.NewIterator());
     pcursor->SeekToFirst();

     CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
@@ -146,7 +146,6 @@
             return error("%s : Deserialize or I/O error - %s", __func__, e.what());
         }
     }
-    delete pcursor;
     stats.nHeight = mapBlockIndex.find(GetBestBlock())->second->nHeight;
     stats.hashSerialized = ss.GetHash();
     stats.nTotalAmount = nTotalAmount;
@@ -178,7 +177,7 @@

 bool CBlockTreeDB::LoadBlockIndexGuts()
 {
-    leveldb::Iterator *pcursor = NewIterator();
+    boost::scoped_ptr<leveldb::Iterator> pcursor(NewIterator());

     CDataStream ssKeySet(SER_DISK, CLIENT_VERSION);
     ssKeySet << make_pair('b', uint256(0));
@@ -224,7 +223,6 @@
             return error("%s : Deserialize or I/O error - %s", __func__, e.what());
         }
     }
-    delete pcursor;
-
-    return true;
-}
+
+    return true;
+}


Some more UMS extended player fixes

Some more UMS extended player fixes

--- src/unit.cpp
+++ src/unit.cpp
@@ -166,6 +166,16 @@
         bw::client_selection_group2[i] = nullptr;
         bw::client_selection_group3[i] = nullptr;
     }
+    // Setting just all 256 player unit pointers to null might overwrite data that should not be touched?
+    // There may be still a few which need to be cleared, selection group 3 starts at player 0x40,
+    // but there's some map terrain data and such before that.
+    bw::first_player_unit.index_overflowing(0x12) = nullptr;
+    bw::first_player_unit.index_overflowing(0x15) = nullptr;
+    bw::first_player_unit.index_overflowing(0x19) = nullptr;
+    bw::first_player_unit.index_overflowing(0x1a) = nullptr;
+    bw::first_player_unit.index_overflowing(0x1b) = nullptr;
+    bw::first_player_unit.index_overflowing(0x1c) = nullptr;
+    bw::first_player_unit.index_overflowing(0x1d) = nullptr;
     std::fill(bw::validation_replay_path.begin(), bw::validation_replay_path.end(), 0);
 }


upnp fix

upnp fix

git-svn-id: 6ed3528c1be4534134272ad6dd050eeaa1f628d3@1559 f43f7eb3-cfe1-5f9d-1b5f-e45aa6702bda

--- src/upnp.cpp
+++ src/upnp.cpp
@@ -339,6 +339,8 @@
 		{
 			d.mapping[0].need_update = true;
 			d.mapping[0].local_port = m_tcp_local_port;
+			if (d.mapping[0].external_port == 0)
+				d.mapping[0].external_port = d.mapping[0].local_port;
 #ifdef TORRENT_UPNP_LOGGING
 			m_log << time_now_string() << " *** Mapping 0 will be updated" << std::endl;
 #endif
@@ -347,6 +349,8 @@
 		{
 			d.mapping[1].need_update = true;
 			d.mapping[1].local_port = m_udp_local_port;
+			if (d.mapping[1].external_port == 0)
+				d.mapping[1].external_port = d.mapping[1].local_port;
 #ifdef TORRENT_UPNP_LOGGING
 			m_log << time_now_string() << " *** Mapping 1 will be updated" << std::endl;
 #endif


If compiled -DDEBUG_LOCKORDER and run with -debug, print out every mutex lock/unlock (helpful for debugging something-is-holding-a-mutex-too-long problems)

--- src/util.cpp
+++ src/util.cpp
@@ -923,16 +923,22 @@

 struct CLockLocation
 {
+    CLockLocation(const char* pszName, const char* pszFile, int nLine)
+    {
+        mutexName = pszName;
+        sourceFile = pszFile;
+        sourceLine = nLine;
+    }
+
+    std::string ToString() const
+    {
+        return mutexName+"  "+sourceFile+":"+itostr(sourceLine);
+    }
+
+private:
     std::string mutexName;
     std::string sourceFile;
     int sourceLine;
-
-    CLockLocation(const char* pszName, const char* pszFile, int nLine)
-    {
-        mutexName = pszName;
-        sourceFile = pszFile;
-        sourceLine = nLine;
-    }
 };

 typedef std::vector< std::pair<CCriticalSection*, CLockLocation> > LockStack;
@@ -950,14 +956,14 @@
     {
         if (i.first == mismatch.first) printf(" (1)");
         if (i.first == mismatch.second) printf(" (2)");
-        printf(" %s  %s:%d\n", i.second.mutexName.c_str(), i.second.sourceFile.c_str(), i.second.sourceLine);
+        printf(" %s\n", i.second.ToString().c_str());
     }
     printf("Current lock order is:\n");
     BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, s1)
     {
         if (i.first == mismatch.first) printf(" (1)");
         if (i.first == mismatch.second) printf(" (2)");
-        printf(" %s  %s:%d\n", i.second.mutexName.c_str(), i.second.sourceFile.c_str(), i.second.sourceLine);
+        printf(" %s\n", i.second.ToString().c_str());
     }
 }

@@ -967,6 +973,7 @@
     if (lockstack.get() == NULL)
         lockstack.reset(new LockStack);

+    if (fDebug) printf("Locking: %s\n", locklocation.ToString().c_str());
     dd_mutex.lock();

     (*lockstack).push_back(std::make_pair(c, locklocation));
@@ -992,7 +999,14 @@

 static void pop_lock()
 {
+    if (fDebug)
+    {
+        const CLockLocation& locklocation = (*lockstack).rbegin()->second;
+        printf("Unlocked: %s\n", locklocation.ToString().c_str());
+    }
+    dd_mutex.lock();
     (*lockstack).pop_back();
+    dd_mutex.unlock();
 }

 void CCriticalSection::Enter(const char* pszName, const char* pszFile, int nLine)


util.cpp branding update

util.cpp branding update

--- src/util.cpp
+++ src/util.cpp
@@ -803,7 +803,7 @@
     pszModule[0] = '\0';
     GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
 #else
-    const char* pszModule = "peershares";
+    const char* pszModule = "Nu";
 #endif
     if (pex)
         snprintf(pszMessage, 1000,
@@ -878,12 +878,12 @@
 {
     namespace fs = boost::filesystem;

-    // Windows: C:\Documents and Settings\username\Application Data\PPCoin
-    // Mac: ~/Library/Application Support/PPCoin
-    // Unix: ~/.peershares
+    // Windows: C:\Documents and Settings\username\Application Data\Nu
+    // Mac: ~/Library/Application Support/Nu
+    // Unix: ~/.Nu
 #ifdef WIN32
     // Windows
-    return MyGetSpecialFolderPath(CSIDL_APPDATA, true) / "Peershares";
+    return MyGetSpecialFolderPath(CSIDL_APPDATA, true) / "Nu";
 #else
     fs::path pathRet;
     char* pszHome = getenv("HOME");
@@ -895,10 +895,10 @@
     // Mac
     pathRet /= "Library/Application Support";
     fs::create_directory(pathRet);
-    return pathRet / "Peershares";
+    return pathRet / "Nu";
 #else
     // Unix
-    return pathRet / ".peershares";
+    return pathRet / ".Nu";
 #endif
 #endif
 }
@@ -1074,7 +1074,7 @@
 {
     namespace fs = boost::filesystem;

-    fs::path pathPidFile(GetArg("-pid", "peershares.pid"));
+    fs::path pathPidFile(GetArg("-pid", "Nu.pid"));
     if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile;
     return pathPidFile;
 }
@@ -1327,7 +1327,7 @@

 boost::filesystem::path static GetAutostartFilePath()
 {
-    return GetAutostartDir() / "peershares.desktop";
+    return GetAutostartDir() / "Nu.desktop";
 }

 bool GetStartOnSystemStartup()


Native versions for AllocateFileRange()

Native versions for AllocateFileRange()

--- src/util.cpp
+++ src/util.cpp
@@ -2,6 +2,15 @@
 // Copyright (c) 2009-2012 The Bitcoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef WIN32
+// for posix_fallocate
+#ifdef __linux__
+#define _POSIX_C_SOURCE 200112L
+#endif
+#include <fcntl.h>
+#include <sys/stat.h>
+#endif

 #include "util.h"
 #include "sync.h"
@@ -1155,6 +1164,35 @@
 // this function tries to make a particular range of a file allocated (corresponding to disk space)
 // it is advisory, and the range specified in the arguments will never contain live data
 void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
+#if defined(WIN32)
+    // Windows-specific version
+    HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file));
+    LARGE_INTEGER nFileSize;
+    int64 nEndPos = (int64)offset + length;
+    nFileSize.u.LowPart = nEndPos & 0xFFFFFFFF;
+    nFileSize.u.HighPart = nEndPos >> 32;
+    SetFilePointerEx(hFile, nFileSize, 0, FILE_BEGIN);
+    SetEndOfFile(hFile);
+#elif defined(MAC_OSX)
+    // OSX specific version
+    fstore_t fst;
+    fst.fst_flags = F_ALLOCATECONTIG;
+    fst.fst_posmode = F_PEOFPOSMODE;
+    fst.fst_offset = 0;
+    fst.fst_length = (off_t)offset + length;
+    fst.fst_bytesalloc = 0;
+    if (fcntl(fileno(file), F_PREALLOCATE, &fst) == -1) {
+        fst.fst_flags = F_ALLOCATEALL;
+        fcntl(fileno(file), F_PREALLOCATE, &fst);
+    }
+    ftruncate(fileno(file), fst.fst_length);
+#elif defined(__linux__)
+    // Version using posix_fallocate
+    off_t nEndPos = (off_t)offset + length;
+    posix_fallocate(fileno(file), 0, nEndPos);
+#else
+    // Fallback version
+    // TODO: just write one byte per block
     static const char buf[65536] = {};
     fseek(file, offset, SEEK_SET);
     while (length > 0) {
@@ -1164,6 +1202,7 @@
         fwrite(buf, 1, now, file); // allowed to fail; this function is advisory anyway
         length -= now;
     }
+#endif
 }

 void ShrinkDebugFile()


$0020 2018/07/31

$0020 2018/07/31

→ Add/Remove Nodes

--- src/util.cpp
+++ src/util.cpp
@@ -1111,8 +1111,10 @@
     + "\ntestnet=0"
     + "\naddnode=sperocoin.ddns.net:55680"
     + "\naddnode=sperocoin.ddns.net:55683"
-    + "\naddnode=coinsmarkets.com:55680"
-    + "\naddnode=dnssperocoin.ddnsking.com:55680";
+    + "\naddnode=dnssperocoin.ddnsking.com:55680"
+    + "\naddnode=18.228.13.3:55680"
+    + "\naddnode=35.232.45.9:55680"
+    + "\naddnode=35.199.96.221:55680";
    pConf.close();
 }


fix build

fix build

Former-commit-id: fcca380676c9a1486bcbb509b37d5ca471ef946f

--- src/util.cpp
+++ src/util.cpp
@@ -1156,7 +1156,7 @@
         }
     #else
         std::string portStr = std::to_string(websocketport);
-        std::string args = std::string("--rpc --rpccorsdomain * --rpcapi eth,net,web3,admin --ws --wsport ") + portStr + std::string(" --wsorigins * --syncmode light --datadir ") + dataDir.c_str();
+        std::string args = std::string("--rpc --rpccorsdomain * --rpcapi eth,net,web3,admin --ws --wsport ") + portStr + std::string(" --wsorigins * --syncmode light --datadir ") + std::string(dataDir.c_str());
         if(bGethTestnet) {
             args += std::string(" --rinkeby");


removed obsolete boost workaround (boost ticket #4258)

--- src/util.cpp
+++ src/util.cpp
@@ -32,16 +32,6 @@
 bool fNoListen = false;
 bool fLogTimestamps = false;
 CMedianFilter<int64> vTimeOffsets(200,0);
-
-
-
-// Workaround for "multiple definition of `_tls_used'"
-// http://svn.boost.org/trac/boost/ticket/4258
-extern "C" void tss_cleanup_implemented() { }
-
-
-
-

 // Init openssl library multithreading support
 static boost::interprocess::interprocess_mutex** ppmutexOpenSSL;


Using a better number generator to avoid conflicts

--- src/utils.cc
+++ src/utils.cc
@@ -87,7 +87,8 @@

 double random_number(const double from, const double to) {
-    std::mt19937 mt(time(0));
+    std::random_device rd;
+    std::mt19937 mt(rd());
     return std::bind(
         std::uniform_real_distribution<>{from, to},
         std::default_random_engine{ mt() })();


added icon for point 'Restart Xterm' in logout submenu

--- src/wmapp.cc
+++ src/wmapp.cc
@@ -887,7 +887,7 @@
             logoutMenu->addItem(_("Restart _Icewm"), -2, null, actionRestart, "restart");

             DProgram *restartXTerm =
-                DProgram::newProgram(app, smActionListener, _("Restart _Xterm"), null, true, 0,
+                DProgram::newProgram(app, smActionListener, _("Restart _Xterm"), (YIcon::getIcon("xterm")), true, 0,
                 		QUOTE(XTERMCMD), noargs);
             if (restartXTerm)
                 logoutMenu->add(new DObjectMenuItem(restartXTerm));


Incorporate two remarks: 1. Use a smart pointer to reduce boilerplate in readDesktopNames. 2. Restore XmbTextListToTextProperty in setNetDesktopNames, but now use a better return code checking, to fix the setting of _NET_DESKTOP_NAMES.

--- src/wmmgr.cc
+++ src/wmmgr.cc
@@ -2608,11 +2608,10 @@
 bool YWindowManager::compareDesktopNames(char **strings, int count) {
     bool changed = false;

-    char **oldWorkspaceNames = new char *[count];
-    for (int i = 0; i < count; i++)
-        oldWorkspaceNames[i] = 0;
-
-    for (int i = 0; i < count && i < workspaceCount(); i++) {
+    // old strings must persist until after the update
+    asmart<csmart> oldWorkspaceNames(new csmart[count]);
+
+    for (int i = 0; i < count; i++) {
         if (workspaceNames[i] != 0) {
             MSG(("Workspace %d: '%s' -> '%s'", i, workspaceNames[i], strings[i]));
             if (strcmp(workspaceNames[i], strings[i])) {
@@ -2631,12 +2630,6 @@
         updateTaskBarNames();
         updateMoveMenu();
     }
-
-    // old strings must persist until after the update
-    for (int i = 0; i < count; i++)
-        if (oldWorkspaceNames[i] != 0)
-            delete[] oldWorkspaceNames[i];
-    delete[] oldWorkspaceNames;

     return changed;
 }
@@ -2748,15 +2741,9 @@
     }
     strings[count] = terminator;
     XTextProperty names;
-    int error = XLocaleNotSupported;
-#ifdef X_HAVE_UTF8_STRING
-    error = Xutf8TextListToTextProperty(xapp->display(), strings, count + 1,
-                                        XUTF8StringStyle, &names);
-#endif
-    if (error != Success) {
-        error = XStringListToTextProperty(strings, count + 1, &names);
-    }
-    if (error == Success) {
+    if (XmbTextListToTextProperty(xapp->display(), strings,
+                                  count + 1, XUTF8StringStyle,
+                                  &names) == Success) {
         XSetTextProperty(xapp->display(), handle(), &names,
                          _XA_NET_DESKTOP_NAMES);
         XFree(names.value);


bugfix DSState_getExecutablePath in llinux

--- src/ydsh.cpp
+++ src/ydsh.cpp
@@ -754,22 +754,23 @@

 #elif __linux__
 char *DSState_getExecutablePath() {
-    const char *selfexe = "/proc/self/exe";
-    struct stat st;
-    if(lstat(selfexe, &st) == -1) {
-        return nullptr;
-    }
-    char *link = static_cast<char*>(malloc(sizeof(char) * (st.st_size + 1)));
-    if(!link) {
-        return nullptr;
-    }
-    ssize_t len = readlink(selfexe, link, sizeof(char) * (st.st_size + 1));
-    if(len < 0 || len > st.st_size) {
-        free(link);
-        return nullptr;
-    }
-    link[len] = '\0';
-    return link;
+    size_t bufSize = 16;
+    char *buf = nullptr;
+    ssize_t len;
+    do {
+        bufSize += (bufSize >> 1u);
+        buf = static_cast<char*>(realloc(buf, sizeof(char) * bufSize));
+        if(!buf) {
+            return nullptr;
+        }
+        len = readlink("/proc/self/exe", buf, bufSize);
+        if(len < 0) {
+            free(buf);
+            return nullptr;
+        }
+    } while(static_cast<size_t>(len) == bufSize);
+    buf[len] = '\0';
+    return buf;
 }

 #else


fixed typos in error messages.

fixed typos in error messages.

--- src/appleseed.studio/mainwindow/mainwindow.cpp
+++ src/appleseed.studio/mainwindow/mainwindow.cpp
@@ -631,7 +631,7 @@
         msgbox.setText("Failed to load the project file " + filepath + ".");
         msgbox.setInformativeText(
             "The project file may be invalid or corrupted. "
-            "Please look to the Log window for details.");
+            "Please look at the Log window for details.");
         msgbox.setStandardButtons(QMessageBox::Ok);
         msgbox.exec();
     }
@@ -644,7 +644,7 @@
         msgbox.setText("Failed to load the built-in project '" + name + "'.");
         msgbox.setInformativeText(
             "The project may be invalid or corrupted. "
-            "Please look to the Log window for details.");
+            "Please look at the Log window for details.");
         msgbox.setStandardButtons(QMessageBox::Ok);
         msgbox.exec();
     }


Persist Project Explorer state and geometry

--- src/appleseed.studio/mainwindow/mainwindow.cpp
+++ src/appleseed.studio/mainwindow/mainwindow.cpp
@@ -136,6 +136,10 @@
     const QSettings settings(SETTINGS_ORGANIZATION, SETTINGS_APPLICATION);
     restoreGeometry(settings.value("main_window_geometry").toByteArray());
     restoreState(settings.value("main_window_state").toByteArray());
+    m_ui->treewidget_project_explorer_scene->header()->restoreGeometry(
+        settings.value("main_window_project_explorer_geometry").toByteArray());
+    m_ui->treewidget_project_explorer_scene->header()->restoreState(
+        settings.value("main_window_project_explorer_state").toByteArray());

     print_startup_information();
     slot_load_settings();
@@ -1055,6 +1059,10 @@
     QSettings settings(SETTINGS_ORGANIZATION, SETTINGS_APPLICATION);
     settings.setValue("main_window_geometry", saveGeometry());
     settings.setValue("main_window_state", saveState());
+    settings.setValue("main_window_project_explorer_geometry",
+        m_ui->treewidget_project_explorer_scene->header()->saveGeometry());
+    settings.setValue("main_window_project_explorer_state",
+        m_ui->treewidget_project_explorer_scene->header()->saveState());

     slot_save_settings();


Esc also undoes the last mover operation

--- src/application/setups/editor/editor_setup.cpp
+++ src/application/setups/editor/editor_setup.cpp
@@ -753,6 +753,7 @@
 		return setup_escape_result::JUST_FETCH;
 	}
 	else if (mover.escape()) {
+		undo();
 		return setup_escape_result::JUST_FETCH;
 	}


refactor(fixed-tvpi): avoid copies in entails

--- include/crab/domains/fixed_tvpi_domain.hpp
+++ include/crab/domains/fixed_tvpi_domain.hpp
@@ -426,42 +426,29 @@
   }

   bool entails(const linear_constraint_t &cst) const override {
-    bool is_bot = false;
+    if (is_bottom()) {
+      return true;
+    } else if (cst.is_tautology()) {
+      return true;
+    } else if (cst.is_contradiction()) {
+      return false;
+    }
+
+    if (m_base_absval.entails(cst)) {
+      return true;
+    }
+
     // The entailment holds if one cst's version is entailed.
     for (auto coefficient: crab_domain_params_man::get().coefficients()) {
       if (can_rewrite_linear_constraint(cst, coefficient)) {
-	// By default, Crab reduces entails(absval, x == COEFF*N) to:
-	//
-	//    is_unsat(absval, x < COEFF*N) and
-	//    is_unsat(absval, x > COEFF*N)
-	//
-	// where is_unsat(cst)= absval.operator+=(cst) and check absval.is_bottom()
-	//
-	// Since strict inequalities are not well supported by abstract
-	// domains over integers, Crab replaces x < y with x <= y-1.
-	//
-	// Constraints such as x <= COEF*y - 1 can be a problem for
-	// fixed_tvpi_domain because -1 is not divisible by COEFF.
-	// Instead, we rewrite first and then negate.
-	//
 	linear_constraint_t gcst = rewrite_linear_constraint(cst, coefficient);
-	linear_constraint_t neg_gcst = gcst.negate();
-	base_domain_t copy(m_base_absval);
-	copy += neg_gcst;
-	is_bot = copy.is_bottom();
-	if (is_bot) {
-	  break;
+	if (m_base_absval.entails(gcst)) {
+	  return true;
 	}
       }
     }
-
-    if (!is_bot) {
-      linear_constraint_t neg_cst = cst.negate();
-      base_domain_t copy(m_base_absval);
-      copy += neg_cst;
-      is_bot = copy.is_bottom();
-    }
-    return is_bot;
+
+    return false;
   }

   void assign(const variable_t &x, const linear_expression_t &e) override {


Updated TDistribution

Updated TDistribution

--- include/fl/distribution/t_distribution.hpp
+++ include/fl/distribution/t_distribution.hpp
@@ -90,9 +90,9 @@
      */
     explicit TDistribution(Real degrees_of_freedom,
                            int dim = DimensionOf<Variate>())
-        : chi2_(degrees_of_freedom),
-          normal_(dim),
-          StdGaussianMappingBase(dim + 1)
+        : StdGaussianMappingBase(dim + 1),
+          chi2_(degrees_of_freedom),
+          normal_(dim)
     {
         static_assert(Variate::SizeAtCompileTime != 0,
                       "Illegal static dimension");
@@ -239,7 +239,7 @@
     /**
      * Sets t-distribution degree-of-freedom
      */
-    virtual void degrees_of_freedom(Real dof) const
+    virtual void degrees_of_freedom(Real dof)
     {
         chi2_.degrees_of_freedom(dof);
         cached_log_pdf_.flag_dirty();
@@ -251,8 +251,6 @@
     Gaussian<Variate> normal_;
     /** \endcond */

-private:
-    CachedLogPdf cached_log_pdf_;

 private:
     class CachedLogPdf
@@ -270,7 +268,7 @@
         {
             if (dirty_) update(t_distr);

-            Variate z = x - location();
+            Variate z = x - t_distr.location();
             Real dof = t_distr.degrees_of_freedom();

             Real quad_term = (z.transpose() * t_distr.normal_.precision() * z);
@@ -288,10 +286,10 @@
             Real dim = t_distr.dimension();
             Real dof = t_distr.degrees_of_freedom();
             const_term_ =
-                boost::lgamma(half * (dof + dim))
-                - boost::lgamma(half * dof)
+                boost::math::lgamma(half * (dof + dim))
+                - boost::math::lgamma(half * dof)
                 - half * (dim * std::log(M_PI * dof))
-                - half * (std::log(t_distr.normal_.determinant()));
+                - half * (std::log(t_distr.normal_.covariance_determinant()));

             const_factor_ = half * (dof + dim);

@@ -304,6 +302,8 @@
     };

     friend class CachedLogPdf;
+
+    mutable CachedLogPdf cached_log_pdf_;
 };

 }


Simplify csv_scanner with a type alias

Simplify csv_scanner with a type alias

--- include/furfurylic/commata/csv_scanner.hpp
+++ include/furfurylic/commata/csv_scanner.hpp
@@ -36,12 +36,13 @@
           class Alloc = std::allocator<Ch>>
 class csv_scanner
 {
+    using string_t = std::basic_string<Ch, Tr, Alloc>;
+
     struct field_scanner
     {
         virtual ~field_scanner() {}
         virtual void field_value(Ch* begin, Ch* end, csv_scanner& me) = 0;
-        virtual void field_value(
-            std::basic_string<Ch, Tr, Alloc>&& value, csv_scanner& me) = 0;
+        virtual void field_value(string_t&& value, csv_scanner& me) = 0;
     };

     struct header_field_scanner : field_scanner
@@ -69,8 +70,7 @@
             }
         }

-        void field_value(
-            std::basic_string<Ch, Tr, Alloc>&& value, csv_scanner& me) override
+        void field_value(string_t&& value, csv_scanner& me) override
         {
             field_value(&value[0], &value[0] + value.size(), me);
         }
@@ -120,8 +120,7 @@
             scanner_.field_value(begin, end);
         }

-        void field_value(
-            std::basic_string<Ch, Tr, Alloc>&& value, csv_scanner&) override
+        void field_value(string_t&& value, csv_scanner&) override
         {
             scanner_.field_value(std::move(value));
         }
@@ -158,7 +157,7 @@
     const Ch* end_;
     std::unique_ptr<header_field_scanner> header_field_scanner_;
     std::vector<std::unique_ptr<body_field_scanner>> scanners_;
-    std::basic_string<Ch, Tr, Alloc> fragmented_value_;
+    string_t fragmented_value_;

 public:
     using char_type = Ch;