HRESULT CWtlHtmlView::GetElementId(std::string id, std::string &val) { _bstr_t bid(id.c_str()); std::string save=val; try { CComPtr<IWebBrowser2> pWebBrowser = this->GetWebBrowser(); if(pWebBrowser==NULL) return E_FAIL; IHTMLDocument2 *document=GetDocument(pWebBrowser); // no garbage cleanup, pointer always good CComPtr<IHTMLElement> elem = GetElement(pWebBrowser, id.c_str()); if(elem==NULL) return E_FAIL; variant_t value; elem->getAttribute(_bstr_t("Value"), NULL, &value ); val="0"; val= (LPCSTR) (bstr_t) value; } catch(...) { val=save; return E_FAIL; } return S_OK; }
// handoff 'key' to 'dst' // void pmaint::pmaint_handoff (chord_node dst, bigint key, cbi cb) { ptr<location> dstloc = host_node->locations->lookup_or_create (dst); assert (dstloc); blockID bid (key, DHASH_CONTENTHASH); trace << host_node->my_ID () << " sending " << key << " to " << dst.x << "\n"; cli->sendblock (dstloc, bid, srv, wrap (this, &pmaint::pmaint_handoff_cb, key, cb)); }
HRESULT CHtmlTableSnapshots::SetElementId(CComPtr<IWebBrowser2> pWebBrowser, std::string id, std::string str) { _bstr_t bstr(str.c_str()); _bstr_t bid(id.c_str()); IHTMLDocument2 *document=GetDocument(pWebBrowser); CComPtr<IHTMLElement> elem = GetElement(pWebBrowser, id.c_str()); if(elem==NULL) return E_FAIL; return elem->put_innerHTML(bstr); }
/* This function is called from 'main' or 'SigTerm'. Its purpose is to clean up * the various loose ends the mud will have running before it shuts down. Put anything * which needs to be added to the shutdown proceedures in here. */ void close_mud( void ) { if( auction->item ) bid( supermob, NULL, "stop" ); if( !DONTSAVE ) { list < descriptor_data * >::iterator ds; log_string( "Saving players...." ); for( ds = dlist.begin( ); ds != dlist.end( ); ++ds ) { descriptor_data *d = *ds; char_data *vch = ( d->character ? d->character : d->original ); if( !vch ) continue; if( !vch->isnpc( ) ) { vch->save( ); log_printf( "%s saved.", vch->name ); d->write( "You have been saved to disk.\033[0m\r\n" ); } } } // Save game world time - Samson 1-21-99 log_string( "Saving game world time...." ); save_timedata( ); // Save ship information - Samson 1-8-01 save_ships( ); fflush( stderr ); /* make sure stderr is flushed */ close( control ); #ifdef IMC imc_shutdown( false ); #endif #if defined(WIN32) /* * Shut down Windows sockets */ WSACleanup( ); /* clean up */ kill_timer( ); /* stop timer thread */ #endif }
HRESULT CWtlHtmlView::SetElementId( std::string id, std::string str) { _bstr_t bstr(str.c_str()); _bstr_t bid(id.c_str()); try { CComPtr<IWebBrowser2> pWebBrowser = this->GetWebBrowser(); if(pWebBrowser==NULL) return E_FAIL; IHTMLDocument2 *document=GetDocument(pWebBrowser); CComPtr<IHTMLElement> elem = GetElement(pWebBrowser, id.c_str()); if(elem==NULL) return E_FAIL; return elem->put_innerHTML(bstr); } catch(...) { return E_FAIL; } return S_OK; }
void deal(int hand_counter, scoreclass & scr) { int suit_number = 0; int bidding_times = 3; cout << "! # " << hand_counter << " !" << endl; cout << "-------" << endl; string dealer; finddealer(hand_counter, dealer); /// in hand.cpp player play = recieve_cards(1); /// recieve_cards() is in recieve_cards.cpp player wplay = recieve_cards(2); play.getorder(); /// Player names don't show up without this being called. cout << endl << "You recieved: " << endl; play.cardnames(); ///These are the north computer players cards player nplay = recieve_cards(3); ///These are the east computer players cards player eplay = recieve_cards(4); int ongoin_bid = 1; ///Why does this start at 1? int westpot = 0; /// Why this name? int northpot = 0; int eastpot = 0; int westscore = 0; int northscore = 0; int eastscore = 0; int playerpot = 0; int playerscore = 0; bool westwin = false; bool northwin = false; bool eastwin = false; bool playerwin = false; int card_passed[8]; /// This should to overwritten by the player classes pass_possibilies :) zero_out_array(8, &card_passed[0]); /// at the beginning of this file. //Names of the cards passed later used in passing() string ppassed1; string ppassed2; string ppassed3; string ppassed4; //The function that will give the players their score and allows the computerized players bid scoring_func( &westscore, &northscore, &eastscore, &playerscore, &play, &wplay, &nplay, &eplay); // Booleans to see if the player passed bool westpass = false; bool northpass = false; bool eastpass = false; bool playerpass = false; int newcounter = 1; /// newcounter -- Used in bid() and bid.cpp functions, int finalbid = 0; ///finalbid -- holds finalbid string winnername, suitname; // Makes the string that will hold the winner's name | suitname int howmanyofsuit(player &); ///In suit.cpp //These return how many of each suit the players have -- Allows them to easily pick their best suit howmanyofsuit(wplay); howmanyofsuit(nplay); howmanyofsuit(eplay); string westsuit; // Holds the best suit for the players // & playersuits(), bid() string northsuit; // & playersuits(), bid() string eastsuit; // & playersuits(), bid() //located in hand.cpp -- Decides the best suit playersuits( westsuit, northsuit, eastsuit, wplay, nplay, eplay); play.getorder(); bool continue_bidding = true; // Used below to keep the loop going // & Used in bid, if statement while(continue_bidding == true) // Bidding Loop { bid(westsuit, northsuit, eastsuit,&newcounter,&bidding_times, &continue_bidding, &ongoin_bid, westpot , northpot, eastpot ,&playerpass, &westpass,&northpass,&eastpass,&westwin, &northwin, &eastwin, &playerwin, &finalbid, &winnername, &suit_number, play); if (suit_number > 0) { switch(suit_number) { case 1: suitname = "Hearts"; break; case 2: suitname = "Diamonds"; break; case 3: suitname = "Spades" ; break; case 4: suitname = "Clubs" ; break; default: error(); break; } } if ( westpass == true &&northpass == true && eastpass == true) { break; } } /// The second call after all the bidding is over to scoring_func scoring_func( &westscore, &northscore, &eastscore, &playerscore, &play, &wplay, &nplay,&eplay); bool firsttime = true; // Used to see if its the pass to the partner who won the deal or the pass back // & 2 x passing() /// Passing is ugly and should only require one function that is 100 times simpler than this one. void new_passing(string & winner, string & suitname, player & play, player & wplay, player & nplay, player & eplay); new_passing(winnername, suitname, play, wplay, nplay, eplay); ///This will require knowing who are partners and then the passing probably will be quite difficult, but we will see. passing(winnername, ppassed1, ppassed2, ppassed3, ppassed4, card_passed[0], card_passed[1],card_passed[2], card_passed[3], card_passed[4], card_passed[5], card_passed[6], card_passed[7], nplay, wplay, eplay, play, suitname, firsttime); // & Ideally these will take only player instances to make them work -- /// This code looks like a project to simplify however. // Rule: Make all your code as easy to read as possible when writing it... name it for what it does. passing(winnername, ppassed1, ppassed2, ppassed3, ppassed4, card_passed[4], card_passed[5],card_passed[6], card_passed[7], card_passed[0], card_passed[1], card_passed[2], card_passed[3], nplay, wplay, eplay, play, suitname, firsttime); cardschangehands(winnername, &card_passed[0], &card_passed[1], &card_passed[2],&card_passed[3],&card_passed [4],&card_passed[5],&card_passed[6],&card_passed[7], play, wplay, nplay, eplay); play.getorder(); /// Why do these need to be called? wplay.getorder(); nplay.getorder(); eplay.getorder(); line(); alltrick test; /// What a terrible name, this sucks play_hand(winnername, suitname, play, wplay, nplay, eplay, test, suit_number); p(); cout << endl << "--Meld--" << endl; cout << " Player is: " << playerscore << endl; cout << " West is : " << westscore << endl; cout << " North is : " << northscore << endl; cout << " East is : " << eastscore << endl; line(); finalscoring(test, scr); cout << "Finalbid: " << finalbid << endl; if (winnername == "Player" || winnername == "North") { if (finalbid <= (playerscore + northscore + scr.scoreteam1()) && (scr.accessplayer() > 0 || scr.accessnorth() >0) && (winnername == "North" || winnername == "Player")) { cout << "You got your bid!" << endl; scr.accessplayer(scr.accessplayer()+playerscore); scr.accessnorth(scr.accessnorth() + northscore); } else { cout << "You got set!" << endl; scr.accessplayer(0); scr.accessnorth(0); } if (scr.accesswest() > 0 || scr.accesseast() > 0) { scr.accesswest(scr.accesswest()+westscore); scr.accesseast(scr.accesseast()+eastscore); } } if (winnername == "West" || winnername == "East") { if (finalbid <= (westscore + eastscore + scr.scoreteam2()) &&( scr.accesswest() > 0 && winnername == "West") || (scr.accesseast() > 0 && winnername == "East")) { cout << "The other team got the bid!" << endl; scr.accesswest(scr.accesswest()+westscore); scr.accesseast(scr.accesseast()+eastscore); } else { cout << "The other team got set!" << endl; scr.accesswest(0); scr.accesseast(0); } if (scr.accessnorth() > 0 || scr.accessplayer() > 0) { scr.accessplayer(scr.accessplayer()+playerscore); scr.accessnorth(scr.accessnorth() + northscore); } } scr.scoreboard(); }