Skip to content

Well this went to heck in a hurry!

February 4, 2015

I put in some scoring, mostly just exposing data that was already there but with an explicit new congratulation routine on a win. It worked fine direct connected to the windows box but when i hokked it to the comcast router so i could have two sessions, it went all to heck. I started getting scores that didn’t make any sense til i noticed that the “secret” number was 999 indicating that a table slot was initialized but not filled in with a secret. It also took many seconds to respond each time – bizarre. Tomorrow I guess.
15-02-04 scoring2

void congratulate(){
	char strbuf[8];
	ipgames[thisipslot]++;//increment win count
	sendconst("You have won ");
		send0s(itoa(ipgames[thisipslot],strbuf));
	sendconst(" games ");
	if (ipgames[thisipslot]>maxipgames){//high scode
		maxipgames=ipgames[thisipslot];
		maxip=thisip;
		sendconst(" - A new high score!");
	}
	sendconst("<p>");
	sendconst("Your IP address is ");sendip(thisip.c); sendconst("<p>");
	sendconst("Best performance was "); sendip(maxip.c); sendconst(" with ");
	send0s(itoa(ipgames[thisipslot],strbuf));
	sendconst(" wins<p>");
}
void sendrespform(int pico, int fermi){
	int sendrc,i;
	static unsigned char hdr1[]="HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
						"<html><body OnLoad=\"document.mf.G.focus();\">"
						"<span style=\"color:#0000A0\">\r\n"
						"<center><h1>Olduino 1802 BAGELS Server</h1></center>";
	static unsigned char gform[]="<p><form name=\"mf\" method=\"GET\">\r\n"
						"<input type=\"text\" name=\"G\">"
						"<input type=\"submit\" value=\"Enter Your Guess\">\r\n"
						"</form>";
	static unsigned char pform[]="<p><form method=\"PUT\">\r\n"
						"<input type=\"submit\" value=\"Press To Play Again\">\r\n"
						"</form>";
	static unsigned char trlr[]="</body></html>\r\n\r\n";
	sendconst(hdr1); 	// Now Send the HTTP Response first part
	sendlit("Your Guess Was: "); 	// Now Send the instructions
	send0s((char *)guess);
	sendlit("  I say ");
	if (fermi==3){
		sendlit("YOU GOT IT!<P>");
		congratulate();
		sendconst(pform);
	} else {//once we're here we're going to send the guess form
		if (pico<0){//flag for duplicate digits
			sendlit("<P>Oh, maybe I didn't tell you.  No two digits are the same.<P>");
		} else if ((pico+fermi)==0){
			sendlit("Bagels!");
		} else{
			for(i=0;i<pico;i++) sendlit("Pico ");
			for(i=0;i<fermi;i++) sendlit("Fermi ");
		}
		sendlit("<P>");
		sendconst(gform); 	// Now Send the rest of the page
		sendlit("<a href=\"http://goo.gl/p4C0Cg\">Olduino</a>: An Arduino for the First of Us<p>");
		sendconst(trlr); 	// Now Send the rest of the page
	}
}
Advertisements

From → web server

One Comment

Trackbacks & Pingbacks

  1. Emergency Debugging Continued | olduino

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: