void DisplayTitles(HSTMT lpStmt, DWORD siDisplaySize, BINDING *pBinding) { TCHAR szTitle[DISPLAY_MAX]; SQLSMALLINT iCol = 1; SetConsole(siDisplaySize + 2, TRUE); for (; pBinding; pBinding = pBinding->sNext) { TRYODBC(lpStmt, SQL_HANDLE_STMT, SQLColAttribute(lpStmt, iCol++, SQL_DESC_NAME, szTitle, sizeof(szTitle), // Note count of bytes! NULL, NULL)); _tprintf(TEXT(DISPLAY_FORMAT_C), PIPE, pBinding->siDisplaySize, pBinding->siDisplaySize, szTitle); } Exit: _tprintf(TEXT(" %c"), PIPE); SetConsole(siDisplaySize + 2, FALSE); _tprintf(TEXT("\n")); }
void DisplayTitles(HSTMT hStmt, DWORD cDisplaySize, BINDING *pBinding) { WCHAR wszTitle[DISPLAY_MAX]; SQLSMALLINT iCol = 1; SetConsole(cDisplaySize+2, TRUE); for (; pBinding; pBinding = pBinding->sNext) { TRYODBC(hStmt, SQL_HANDLE_STMT, SQLColAttribute(hStmt, iCol++, SQL_DESC_NAME, wszTitle, sizeof(wszTitle), // Note count of bytes! NULL, NULL)); wprintf(DISPLAY_FORMAT_C, PIPE, pBinding->cDisplaySize, pBinding->cDisplaySize, wszTitle); } Exit: wprintf(L" %c", PIPE); SetConsole(cDisplaySize+2, FALSE); wprintf(L"\n"); }
void DisplayResults(HSTMT lpStmt, SQLSMALLINT cCols) { BINDING *pFirstBinding, *pThisBinding; SQLSMALLINT siDisplaySize; RETCODE RetCode; int iCount = 0; // Allocate memory for each column AllocateBindings(lpStmt, cCols, &pFirstBinding, &siDisplaySize); // Set the display mode and write the titles DisplayTitles(lpStmt, siDisplaySize, pFirstBinding); // Fetch and display the data do { // Fetch a row if (iCount++ >= gHeight - 2) { char szInput[100]; printf(" "); SetConsole(siDisplaySize + 2, TRUE); printf(" Press ENTER to continue, Q to quit"); printf("%d", gHeight); SetConsole(siDisplaySize + 2, FALSE); gets(szInput); if ((*szInput == 'Q') || (*szInput == 'q')) goto Exit; iCount = 1; DisplayTitles(lpStmt, siDisplaySize, pFirstBinding); } TRYODBC(lpStmt, SQL_HANDLE_STMT, RetCode = SQLFetch(lpStmt)); if (RetCode == SQL_NO_DATA_FOUND) break; if (RetCode == SQL_NO_DATA) break; // Display the data. Ignore truncations for (pThisBinding = pFirstBinding; pThisBinding; pThisBinding = pThisBinding->sNext) { if (pThisBinding->indPtr != SQL_NULL_DATA) { _tprintf(pThisBinding->fChar ? TEXT(DISPLAY_FORMAT_C) : TEXT(DISPLAY_FORMAT), PIPE, pThisBinding->siDisplaySize, pThisBinding->siDisplaySize, pThisBinding->szBuffer); } else { _tprintf(TEXT(DISPLAY_FORMAT_C), PIPE, pThisBinding->siDisplaySize, pThisBinding->siDisplaySize, "<NULL>"); } } _tprintf(TEXT(" %c\n"), PIPE); } while ( 1); SetConsole(siDisplaySize + 2, TRUE); printf("%*.*s", siDisplaySize + 2, siDisplaySize + 2, " "); SetConsole(siDisplaySize + 2, FALSE); printf("\n"); Exit: // Clean up the allocated buffers while (pFirstBinding) { pThisBinding = pFirstBinding->sNext; free(pFirstBinding->szBuffer); free(pFirstBinding); pFirstBinding = pThisBinding; } }
bool CCheatMgr::Process( CheatCode nCheatCode, CParsedMsgW const& cMsg ) { if ( nCheatCode <= CHEAT_NONE || nCheatCode >= CHEAT_MAX ) return false; #ifdef _FINAL // Don't do cheats in multiplayer... if (IsMultiplayerGameClient()) { // Well, okay, let them toggle between 1st and 3rd person ;) // and, well, blood is pretty cool... switch ( nCheatCode ) { case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // boot players BootPlayer(cMsg); break; default : return false; break; } m_bPlayerCheated = true; return true; } #else // _FINAL // Only allow cheats in MP if console variable turned on. if( IsMultiplayerGameClient( )) { float fVal = 0.0f; g_pLTClient->GetSConValueFloat( "AllowMPCheats", fVal ); bool bAllowMPCheats = fVal != 0.0f; if( !bAllowMPCheats ) return false; } #endif // _FINAL // process cheat codes switch ( nCheatCode ) { case CHEAT_GOD: // god mode toggle SetGodMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_ARMOR: // full armor SetArmor(); break; case CHEAT_HEALTH: // full health SetHealth(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_VERSION: // display version info Version(); break; case CHEAT_INVISIBLE: // time to mess with the AI SetInvisible(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_BODYGOLFING: // bodies fly far //currently unimplemented... // BodyGolfing(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS: // show/hide player position SetPos(!s_CheatInfo[nCheatCode].bActive); break; #ifndef _DEMO case CHEAT_KFA: // give em everything SetKFA(); break; case CHEAT_AMMO: // full ammo SetAmmo(); break; case CHEAT_MODSQUAD: // give all mods for current weapons ModSquad(); break; case CHEAT_CONSOLE: SetConsole(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // exit the current mission BootPlayer(cMsg); break; case CHEAT_FULL_WEAPONS: // give all weapons SetFullWeapons(); break; case CHEAT_FULL_GEAR: // give all gear FullGear(); break; case CHEAT_TEARS: // toggle tears cheat Tears(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_GIMMEGUN: GimmeGun( cMsg ); break; case CHEAT_GIMMEMOD: GimmeMod( cMsg ); break; case CHEAT_GIMMEGEAR: GimmeGear( cMsg ); break; case CHEAT_GIMMEAMMO: GimmeAmmo( cMsg ); break; case CHEAT_ENDGAME: ToggleEndgameFlag(); break; #ifndef _FINAL case CHEAT_CHASETOGGLE: // toggle 3rd person view ChaseToggle(); break; case CHEAT_CLIP: // toggle clipping mode SetClipMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TELEPORT: // teleport to beginning Teleport(); break; case CHEAT_CAM_POSROT: // show/hide camera position/rotation SetCamPosRot(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON: // toggle adjust of weapon pos PosWeapon(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_REMOVEAI: // remove all ai RemoveAI(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TRIGGERBOX: // toggle trigger boxes on/off TriggerBox(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS1STCAM: // toggle 1st person camera adjust on/off Pos1stCam(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_SAVEVEHICLE: // save the vehicle tweaks to the bute file SaveVehicle( ); break; #endif // _FINAL #endif // _DEMO default: return false; // skip setting global cheat indicator for unhandled cheats } m_bPlayerCheated = true; return true; }
bool CCheatMgr::Process( CheatCode nCheatCode, CParsedMsg &cMsg ) { if ( nCheatCode <= CHEAT_NONE || nCheatCode >= CHEAT_MAX ) return false; #ifdef _FINAL // Don't do cheats in multiplayer... if (IsMultiplayerGame()) { // Well, okay, let them toggle between 1st and 3rd person ;) // and, well, blood is pretty cool... switch ( nCheatCode ) { case CHEAT_CHASETOGGLE: ChaseToggle(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // boot players BootPlayer(cMsg); break; default : return false; break; } m_bPlayerCheated = LTTRUE; return true; } #endif // _FINAL // process cheat codes switch ( nCheatCode ) { case CHEAT_GOD: // god mode toggle SetGodMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_SKILLZ: // give em skill points GetSkills(); break; case CHEAT_ARMOR: // full armor SetArmor(); break; case CHEAT_HEALTH: // full health SetHealth(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_VERSION: // display version info Version(); break; case CHEAT_BUILDGUID: // display build guid BuildGuid(); break; case CHEAT_INVISIBLE: // time to mess with the AI SetInvisible(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_BODYGOLFING: // bodies fly far BodyGolfing(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS: // show/hide player position SetPos(!s_CheatInfo[nCheatCode].bActive); break; #ifndef _TO2DEMO case CHEAT_KFA: // give em everything SetKFA(); break; case CHEAT_AMMO: // full ammo SetAmmo(); break; case CHEAT_MODSQUAD: // give all mods for current weapons ModSquad(); break; case CHEAT_CONSOLE: SetConsole(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // exit the current mission BootPlayer(cMsg); break; case CHEAT_FULL_WEAPONS: // give all weapons SetFullWeapons(); break; case CHEAT_SNOWMOBILE: // spawn in snowmobile Snowmobile(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_FULL_GEAR: // give all gear FullGear(); break; case CHEAT_TEARS: // toggle tears cheat Tears(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_GIMMEGUN: GimmeGun( cMsg ); break; case CHEAT_GIMMEMOD: GimmeMod( cMsg ); break; case CHEAT_GIMMEGEAR: GimmeGear( cMsg ); break; case CHEAT_GIMMEAMMO: GimmeAmmo( cMsg ); break; case CHEAT_ENDGAME: ToggleEndgameFlag(); break; #ifndef _FINAL case CHEAT_CHASETOGGLE: // toggle 3rd person view ChaseToggle(); break; case CHEAT_CLIP: // toggle clipping mode SetClipMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TELEPORT: // teleport to beginning Teleport(); break; case CHEAT_CAM_POSROT: // show/hide camera position/rotation SetCamPosRot(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON: // toggle adjust of weapon pos PosWeapon(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON_MUZZLE: // toggle adjust of weapon muzzle pos PosWeaponMuzzle(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_WEAPON_BREACHOFFSET: // toggle adjust of weapon breach offset pos WeaponBreachOffset(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_LIGHTSCALE: // toggle client light scale offset LightScale(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_LIGHTADD: // toggle client light add offset LightAdd(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_FOV: // toggle fov cheat FOV(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_REMOVEAI: // remove all ai RemoveAI(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TRIGGERBOX: // toggle trigger boxes on/off TriggerBox(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS1STCAM: // toggle 1st person camera adjust on/off Pos1stCam(!s_CheatInfo[nCheatCode].bActive); break; #endif // _FINAL #endif // _TO2DEMO default: return false; // skip setting global cheat indicator for unhandled cheats } m_bPlayerCheated = LTTRUE; return true; }
/******************************************************************************************************* * GANE ENGINE - handles the looping of the game *******************************************************************************************************/ void GameEngine() { // user input variables const int userInputLimit = 11; char userInput[userInputLimit] = {}; bool humanFinished = false; bool moveHuman = false; StringOO humanMove = "move south"; int loopCount = 0; // location variables const int locationNum = 11; Location *Locations[locationNum] = {}; int prevLocation = 0; int newLocation = 0; int finishLocation = locationNum - 1; // human player variables int humanLoc = 0; StringOO name = "Bruce"; int strength = 10; int health = 100; int luck = 10; int intellegence = 10; // enemy variables const int enemyNum = 5; Enemy * Enemies[enemyNum] = {}; // challenges variables const int challengeNum = 16; Challenge *Challenges[challengeNum] = {}; // initialise Locations InitLocations(Locations); // initialise human Human Human(humanLoc, name, strength, health, luck, intellegence); // initialise Enemies InitEnemies(Enemies, enemyNum); // initialise Challenges InitChallenges(Challenges); //AllocateChallenges(Locations, locationNum); AllocateChallengesManually(Locations, locationNum); AddEnemyToChallenge(Challenges, enemyNum, challengeNum); // initial splash screen SetConsole(); StartText(Human); // Game loop while (!humanFinished) { // print out details of room std::cout << Locations[Human.GetLocation()]->GetDescription() << std::endl; while (!moveHuman) { // get user to enter move std::cout << "+ "; std::cin.getline(userInput, userInputLimit); std::cout << std::endl; humanMove = userInput; if (loopCount == 5) { std::cout << "\n ENOUGH ALREADY...YOUR MOVING SOUTH!! \n\n"; //bored of guesses humanMove = "move south"; loopCount = 0; } // determine the new location newLocation = PlayerMove(Human, humanMove, Locations[Human.GetLocation()]->GetAjacentLoc()); // validate users move and if validate change their location if (ValidateMove(newLocation, prevLocation)) { // set challenge user has to perform before progrogressing to the next room Human.SetChallenge(Locations[Human.GetLocation()]->GetPathChallenge(Human.GetHeading())); // challenge User Challenge *ChallengePtr = Challenges[Human.GetChallenge()]; ApplyChallenge(ChallengePtr, Human, Enemies); // move user to new location prevLocation = Human.GetLocation(); Human.SetPrevHeading(Human.GetHeading()); Human.SetLocation(newLocation); moveHuman = true; loopCount = 0; std::cout << "\n***----------------------------* pop! *-------------------------------------**\n\n"; } else { // invalid move try again moveHuman = false; loopCount++; } } // reset move moveHuman = false; //check if user is in the finish location if (Human.GetLocation() == finishLocation) { humanFinished = true; std::cout << Locations[Human.GetLocation()]->GetDescription() << std::endl; FinishText(Human); } } //DestroyEnemies(Enemies, enemyNum); for (int i = 0; i < enemyNum; i++) { delete Enemies[i]; } //DestroyChallenges(Challenges, challengeNum); for (int i = 0; i < challengeNum; i++) { delete Challenges[i]; } //DestroyLocations(Locations, locationNum); for (int i = 0; i < locationNum; i++) { delete Locations[i]; } }
//*================================================================================= //*原型: void TServer::RunService(LPCTSTR pszServiceName, //* LPCTSTR pszDisplayName, LPSTR lpCmdLine) //*功能: 服务器入口 //*参数: pszServiceName -- 服务器名称 //* pszDisplayName -- 服务器显示名称 //* lpCmdLine -- 命令行 //*返回: 无 //*说明: WINNT服务器基类 //*================================================================================= void TServer::RunService(LPCTSTR pszServiceName, LPCTSTR pszDisplayName, LPSTR lpCmdLine) { //检测操作系统版本 CheckOSVersion(); m_pszServiceName = pszServiceName ; m_pszDisplayName = pszDisplayName ; bDebug = TRUE; //add by lina 20050311 //帮助 if( !lstrcmp(lpCmdLine, "help") ) { PrintHelp(); return ; } //调试模式(仅供现场测试及内部测试用) else if( !lstrcmp(lpCmdLine, "debug") ) { bDebug = TRUE ; } //安装为服务器 else if( !lstrcmp(lpCmdLine, "install") ) { InstallService(m_pszServiceName, m_pszDisplayName); return ; } //删除服务器 else if( !lstrcmp(lpCmdLine, "delete") ) { DeleteService(m_pszServiceName); return ; } //Start服务器 else if( !lstrcmp(lpCmdLine, "start") ) { StartServer(m_pszServiceName); return ; } //停止服务器 else if( !lstrcmp(lpCmdLine, "stop") ) { WriteLog("停止服务器!!!!........\n"); printf("停止服务器!!!!........\n"); //StopServer(m_pszServiceName); EndService(m_pszServiceName); return ; } CheckInstance(); /*SECURITY_ATTRIBUTES sa; SECURITY_DESCRIPTOR sd; sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = &sd; if( InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION) ) { SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE); } m_hShutdown = CreateEvent(&sa, FALSE, FALSE, "__SMART_SERVER_SHUTDOWN__"); if( m_hShutdown == NULL ) { throw TException("Call CreateEvent() Faild!", GetLastError()); }*/ if( bDebug ) { SetConsole(); ServiceMain(0, NULL); } else { SERVICE_TABLE_ENTRY DispatchTable[] = { {(LPTSTR)m_pszServiceName, ServiceMain}, {NULL, NULL} }; //先试着从服务管理器中启动, 如失败, 则用无窗口的方式启动 if( !StartServiceCtrlDispatcher(DispatchTable)) { /* bDebug = TRUE; ServiceMain(0, NULL); MSG msg; while (GetMessage(&msg, 0, 0, 0)) DispatchMessage(&msg); */ } } }
void DisplayResults(HSTMT hStmt, SQLSMALLINT cCols) { BINDING *pFirstBinding, *pThisBinding; SQLSMALLINT cDisplaySize; RETCODE RetCode = SQL_SUCCESS; int iCount = 0; // Allocate memory for each column AllocateBindings(hStmt, cCols, &pFirstBinding, &cDisplaySize); // Set the display mode and write the titles DisplayTitles(hStmt, cDisplaySize+1, pFirstBinding); // Fetch and display the data bool fNoData = false; do { // Fetch a row if (iCount++ >= gHeight - 2) { int nInputChar; bool fEnterReceived = false; while(!fEnterReceived) { wprintf(L" "); SetConsole(cDisplaySize+2, TRUE); wprintf(L" Press ENTER to continue, Q to quit (height:%hd)", gHeight); SetConsole(cDisplaySize+2, FALSE); nInputChar = _getch(); wprintf(L"\n"); if ((nInputChar == 'Q') || (nInputChar == 'q')) { goto Exit; } else if ('\r' == nInputChar) { fEnterReceived = true; } // else loop back to display prompt again } iCount = 1; DisplayTitles(hStmt, cDisplaySize+1, pFirstBinding); } TRYODBC(hStmt, SQL_HANDLE_STMT, RetCode = SQLFetch(hStmt)); if (RetCode == SQL_NO_DATA_FOUND) { fNoData = true; } else { // Display the data. Ignore truncations for (pThisBinding = pFirstBinding; pThisBinding; pThisBinding = pThisBinding->sNext) { if (pThisBinding->indPtr != SQL_NULL_DATA) { wprintf(pThisBinding->fChar ? DISPLAY_FORMAT_C:DISPLAY_FORMAT, PIPE, pThisBinding->cDisplaySize, pThisBinding->cDisplaySize, pThisBinding->wszBuffer); } else { wprintf(DISPLAY_FORMAT_C, PIPE, pThisBinding->cDisplaySize, pThisBinding->cDisplaySize, L"<NULL>"); } } wprintf(L" %c\n",PIPE); } } while (!fNoData); SetConsole(cDisplaySize+2, TRUE); wprintf(L"%*.*s", cDisplaySize+2, cDisplaySize+2, L" "); SetConsole(cDisplaySize+2, FALSE); wprintf(L"\n"); Exit: // Clean up the allocated buffers while (pFirstBinding) { pThisBinding = pFirstBinding->sNext; free(pFirstBinding->wszBuffer); free(pFirstBinding); pFirstBinding = pThisBinding; } }