这篇教程C++ Console函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Console函数的典型用法代码示例。如果您正苦于以下问题:C++ Console函数的具体用法?C++ Console怎么用?C++ Console使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Console函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: str_formatvoid CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID){ void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker); CPlayer *pPlayer = m_apPlayers[ClientID]; if(!pRawMsg) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); return; } if(MsgID == NETMSGTYPE_CL_SAY) { CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; int Team = pMsg->m_Team; if(Team) Team = pPlayer->GetTeam(); else Team = CGameContext::CHAT_ALL; if(g_Config.m_SvSpamprotection && pPlayer->m_Last_Chat && pPlayer->m_Last_Chat+Server()->TickSpeed() > Server()->Tick()) return; pPlayer->m_Last_Chat = Server()->Tick(); // check for invalid chars unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; while (*pMessage) { if(*pMessage < 32) *pMessage = ' '; pMessage++; } SendChat(ClientID, Team, pMsg->m_pMessage); } else if(MsgID == NETMSGTYPE_CL_CALLVOTE) { if(g_Config.m_SvSpamprotection && pPlayer->m_Last_VoteTry && pPlayer->m_Last_VoteTry+Server()->TickSpeed()*3 > Server()->Tick()) return; int64 Now = Server()->Tick(); pPlayer->m_Last_VoteTry = Now; if(pPlayer->GetTeam() == TEAM_SPECTATORS) { SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); return; } if(m_VoteCloseTime) { SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); return; } int Timeleft = pPlayer->m_Last_VoteCall + Server()->TickSpeed()*60 - Now; if(pPlayer->m_Last_VoteCall && Timeleft > 0) { char aChatmsg[512] = {0}; str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); SendChatTarget(ClientID, aChatmsg); return; } char aChatmsg[512] = {0}; char aDesc[512] = {0}; char aCmd[512] = {0}; CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg; if(str_comp_nocase(pMsg->m_Type, "option") == 0) { CVoteOption *pOption = m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pMsg->m_Value, pOption->m_aCommand) == 0) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s'", Server()->ClientName(ClientID), pOption->m_aCommand); str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aCommand); str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); break; } pOption = pOption->m_pNext; } if(!pOption) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); SendChatTarget(ClientID, aChatmsg); return; } } else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { if(!g_Config.m_SvVoteKick) { SendChatTarget(ClientID, "Server does not allow voting to kick players"); return; }//.........这里部分代码省略.........
开发者ID:CoolerMAN,项目名称:tdtw,代码行数:101,
示例2: Consolevoid CMapLayers::OnConsoleInit(){ Console()->Chain("cl_background_map", ConchainBackgroundMap, this);}
开发者ID:4a4ik,项目名称:teeworlds,代码行数:4,
示例3: mem_zerovoid CGameClient::OnNewSnapshot(){ m_NewTick = true; // clear out the invalid pointers mem_zero(&g_GameClient.m_Snap, sizeof(g_GameClient.m_Snap)); m_Snap.m_LocalClientID = -1; // secure snapshot { int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT); for(int Index = 0; Index < Num; Index++) { IClient::CSnapItem Item; void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, Index, &Item); if(m_NetObjHandler.ValidateObj(Item.m_Type, pData, Item.m_DataSize) != 0) { if(g_Config.m_Debug) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "invalidated index=%d type=%d (%s) size=%d id=%d", Index, Item.m_Type, m_NetObjHandler.GetObjName(Item.m_Type), Item.m_DataSize, Item.m_ID); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); } Client()->SnapInvalidateItem(IClient::SNAP_CURRENT, Index); } } } ProcessEvents(); if(g_Config.m_DbgStress) { if((Client()->GameTick()%100) == 0) { char aMessage[64]; int MsgLen = rand()%(sizeof(aMessage)-1); for(int i = 0; i < MsgLen; i++) aMessage[i] = 'a'+(rand()%('z'-'a')); aMessage[MsgLen] = 0; CNetMsg_Cl_Say Msg; Msg.m_Team = rand()&1; Msg.m_pMessage = aMessage; Client()->SendPackMsg(&Msg, MSGFLAG_VITAL); } } // go trough all the items in the snapshot and gather the info we want { m_Snap.m_aTeamSize[TEAM_RED] = m_Snap.m_aTeamSize[TEAM_BLUE] = 0; int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT); for(int i = 0; i < Num; i++) { IClient::CSnapItem Item; const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item); if(Item.m_Type == NETOBJTYPE_CLIENTINFO) { const CNetObj_ClientInfo *pInfo = (const CNetObj_ClientInfo *)pData; int ClientID = Item.m_ID; IntsToStr(&pInfo->m_Name0, 8, m_aClients[ClientID].m_aName); IntsToStr(&pInfo->m_Clan0, 3, m_aClients[ClientID].m_aClan); m_aClients[ClientID].m_Country = pInfo->m_Country; IntsToStr(&pInfo->m_Skin0, 6, m_aClients[ClientID].m_aSkinName); m_aClients[ClientID].m_UseCustomColor = pInfo->m_UseCustomColor; m_aClients[ClientID].m_ColorBody = pInfo->m_ColorBody; m_aClients[ClientID].m_ColorFeet = pInfo->m_ColorFeet; // prepare the info if(m_aClients[ClientID].m_aSkinName[0] == 'x' || m_aClients[ClientID].m_aSkinName[1] == '_') str_copy(m_aClients[ClientID].m_aSkinName, "default", 64); m_aClients[ClientID].m_SkinInfo.m_ColorBody = m_pSkins->GetColorV4(m_aClients[ClientID].m_ColorBody); m_aClients[ClientID].m_SkinInfo.m_ColorFeet = m_pSkins->GetColorV4(m_aClients[ClientID].m_ColorFeet); m_aClients[ClientID].m_SkinInfo.m_Size = 64; // find new skin m_aClients[ClientID].m_SkinID = g_GameClient.m_pSkins->Find(m_aClients[ClientID].m_aSkinName); if(m_aClients[ClientID].m_SkinID < 0) { m_aClients[ClientID].m_SkinID = g_GameClient.m_pSkins->Find("default"); if(m_aClients[ClientID].m_SkinID < 0) m_aClients[ClientID].m_SkinID = 0; } if(m_aClients[ClientID].m_UseCustomColor) m_aClients[ClientID].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(m_aClients[ClientID].m_SkinID)->m_ColorTexture; else { m_aClients[ClientID].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(m_aClients[ClientID].m_SkinID)->m_OrgTexture; m_aClients[ClientID].m_SkinInfo.m_ColorBody = vec4(1,1,1,1); m_aClients[ClientID].m_SkinInfo.m_ColorFeet = vec4(1,1,1,1); } m_aClients[ClientID].UpdateRenderInfo(); } else if(Item.m_Type == NETOBJTYPE_PLAYERINFO)//.........这里部分代码省略.........
开发者ID:Milkax3,项目名称:TRP--TeeRolePlay-,代码行数:101,
示例4: while//.........这里部分代码省略......... // on demo playback use local id from snap directly, // since m_LocalIDs isn't valid there if (LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName)) Highlighted = true; } m_aLines[m_CurrentLine].m_Highlighted = Highlighted; if(ClientID == -1) // server message { str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName)); str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), "%s", pLine); } else { if(m_pClient->m_aClients[ClientID].m_Team == TEAM_SPECTATORS) m_aLines[m_CurrentLine].m_NameColor = TEAM_SPECTATORS; if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS) { if(m_pClient->m_aClients[ClientID].m_Team == TEAM_RED) m_aLines[m_CurrentLine].m_NameColor = TEAM_RED; else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE) m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE; } if (Team == 2) // whisper send { str_format(m_aLines[m_CurrentLine].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName), "→ %s", m_pClient->m_aClients[ClientID].m_aName); m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE; m_aLines[m_CurrentLine].m_Highlighted = false; m_aLines[m_CurrentLine].m_Team = 0; Highlighted = false; } else if (Team == 3) // whisper recv { str_format(m_aLines[m_CurrentLine].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName), "← %s", m_pClient->m_aClients[ClientID].m_aName); m_aLines[m_CurrentLine].m_NameColor = TEAM_RED; m_aLines[m_CurrentLine].m_Highlighted = true; m_aLines[m_CurrentLine].m_Team = 0; Highlighted = true; } else { str_copy(m_aLines[m_CurrentLine].m_aName, m_pClient->m_aClients[ClientID].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName)); } str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), ": %s", pLine); } char aBuf[1024]; str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, Team >= 2?"whisper":(m_aLines[m_CurrentLine].m_Team?"teamchat":"chat"), aBuf, Highlighted); } // play sound int64 Now = time_get(); if(ClientID == -1) { if(Now-m_aLastSoundPlayed[CHAT_SERVER] >= time_freq()*3/10) { if(g_Config.m_SndServerMessage) { m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0); m_aLastSoundPlayed[CHAT_SERVER] = Now; } } } else if(Highlighted) { if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10) {#ifdef CONF_PLATFORM_MACOSX char aBuf[1024]; str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); CNotification::notify("DDNet-Chat", aBuf);#else Graphics()->NotifyWindow();#endif if(g_Config.m_SndHighlight) { m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now; } } } else if(Team != 2) { if(Now-m_aLastSoundPlayed[CHAT_CLIENT] >= time_freq()*3/10) { if ((g_Config.m_SndTeamChat || !m_aLines[m_CurrentLine].m_Team) && (g_Config.m_SndChat || m_aLines[m_CurrentLine].m_Team)) { m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); m_aLastSoundPlayed[CHAT_CLIENT] = Now; } } }}
开发者ID:hamidkag,项目名称:TBlock,代码行数:101,
示例5: ExtractArgumentsint MaskedStretchProcess::ProcessCommandLine( const StringList& argv ) const{ ArgumentList arguments = ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards ); MaskedStretchInstance instance( this ); bool launchInterface = false; int count = 0; for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i ) { const Argument& arg = *i; if ( arg.IsNumeric() ) { if ( arg.Id() == "b" || arg.Id() == "-background" ) { double b = arg.NumericValue(); if ( b < TheMSTargetBackgroundParameter->MinimumValue() || b > TheMSTargetBackgroundParameter->MaximumValue() ) throw Error( "Target background parameter out of range" ); instance.p_targetBackground = b; } else if ( arg.Id() == "n" || arg.Id() == "-iterations" ) { int n = TruncInt( arg.NumericValue() ); if ( n < int( TheMSNumberOfIterationsParameter->MinimumValue() ) || n > int( TheMSNumberOfIterationsParameter->MaximumValue() ) ) throw Error( "Number of iterations parameter out of range" ); instance.p_numberOfIterations = n; } else throw Error( "Unknown numeric argument: " + arg.Token() ); } else if ( arg.IsString() ) { if ( arg.Id() == "m" || arg.Id() == "-mask-type" ) { if ( arg.StringValue() == "I" || arg.StringValue() == "intensity" ) instance.p_maskType = MSMaskType::Intensity; else if ( arg.StringValue() == "V" || arg.StringValue() == "value" ) instance.p_maskType = MSMaskType::Value; } else throw Error( "Unknown string argument: " + arg.Token() ); } else if ( arg.IsSwitch() ) { throw Error( "Unknown switch argument: " + arg.Token() ); } else if ( arg.IsLiteral() ) { if ( arg.Id() == "-interface" ) launchInterface = true; else if ( arg.Id() == "-help" ) { ShowHelp(); return 0; } else throw Error( "Unknown argument: " + arg.Token() ); } else if ( arg.IsItemList() ) { ++count; if ( arg.Items().IsEmpty() ) { Console().WriteLn( "No view(s) found: " + arg.Token() ); continue; } for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j ) { View v = View::ViewById( *j ); if ( v.IsNull() ) throw Error( "No such view: " + *j ); instance.LaunchOn( v ); } } } if ( launchInterface ) instance.LaunchInterface(); else if ( count == 0 ) { if ( ImageWindow::ActiveWindow().IsNull() ) throw Error( "There is no active image window." ); instance.LaunchOnCurrentView(); } return 0;}
开发者ID:morserover,项目名称:PCL,代码行数:94,
示例6: Storagevoid CCountryFlags::LoadCountryflagsIndexfile(){ IOHANDLE File = Storage()->OpenFile("countryflags/index.txt", IOFLAG_READ, IStorage::TYPE_ALL); if(!File) { Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "couldn't open index file"); return; } char aOrigin[128]; CLineReader LineReader; LineReader.Init(File); char *pLine; while((pLine = LineReader.Get())) { if(!str_length(pLine) || pLine[0] == '#') // skip empty lines and comments continue; str_copy(aOrigin, pLine, sizeof(aOrigin)); char *pReplacement = LineReader.Get(); if(!pReplacement) { Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "unexpected end of index file"); break; } if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "malform replacement for index '%s'", aOrigin); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); continue; } int CountryCode = str_toint(pReplacement+3); if(CountryCode < CODE_LB || CountryCode > CODE_UB) { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "country code '%i' not within valid code range [%i..%i]", CountryCode, CODE_LB, CODE_UB); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); continue; } // load the graphic file char aBuf[128]; str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin); CImageInfo Info; if(!Graphics()->LoadPNG(&Info, aBuf, IStorage::TYPE_ALL)) { char aMsg[128]; str_format(aMsg, sizeof(aMsg), "failed to load '%s'", aBuf); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aMsg); continue; } // add entry CCountryFlag CountryFlag; CountryFlag.m_CountryCode = CountryCode; str_copy(CountryFlag.m_aCountryCodeString, aOrigin, sizeof(CountryFlag.m_aCountryCodeString)); CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); mem_free(Info.m_pData); str_format(aBuf, sizeof(aBuf), "loaded country flag '%s'", aOrigin); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); m_aCountryFlags.add(CountryFlag); } io_close(File); mem_zero(m_CodeIndexLUT, sizeof(m_CodeIndexLUT)); for(int i = 0; i < m_aCountryFlags.size(); ++i) m_CodeIndexLUT[max(0, (m_aCountryFlags[i].m_CountryCode-CODE_LB)%CODE_RANGE)] = i+1;}
开发者ID:MJavad,项目名称:MnTee,代码行数:71,
示例7: whilevoid CChat::AddLine(int ClientID, int Team, const char *pLine){ if(*pLine == 0 || (ClientID != -1 && (!g_Config.m_ClShowsocial || m_pClient->m_aClients[ClientID].m_aName[0] == '/0' || // unknown client m_pClient->m_aClients[ClientID].m_ChatIgnore || (m_pClient->m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend)))) return; // trim right and set maximum length to 128 utf8-characters int Length = 0; const char *pStr = pLine; const char *pEnd = 0; while(*pStr) { const char *pStrOld = pStr; int Code = str_utf8_decode(&pStr); // check if unicode is not empty if(Code > 0x20 && Code != 0xA0 && Code != 0x034F && (Code < 0x2000 || Code > 0x200F) && (Code < 0x2028 || Code > 0x202F) && (Code < 0x205F || Code > 0x2064) && (Code < 0x206A || Code > 0x206F) && (Code < 0xFE00 || Code > 0xFE0F) && Code != 0xFEFF && (Code < 0xFFF9 || Code > 0xFFFC)) { pEnd = 0; } else if(pEnd == 0) pEnd = pStrOld; if(++Length >= 127) { *(const_cast<char *>(pStr)) = 0; break; } } if(pEnd != 0) *(const_cast<char *>(pEnd)) = 0; bool Highlighted = false; char *p = const_cast<char*>(pLine); while(*p) { Highlighted = false; pLine = p; // find line seperator and strip multiline while(*p) { if(*p++ == '/n') { *(p-1) = 0; break; } } m_CurrentLine = (m_CurrentLine+1)%MAX_LINES; m_aLines[m_CurrentLine].m_Time = time_get(); m_aLines[m_CurrentLine].m_YOffset[0] = -1.0f; m_aLines[m_CurrentLine].m_YOffset[1] = -1.0f; m_aLines[m_CurrentLine].m_ClientID = ClientID; m_aLines[m_CurrentLine].m_Team = Team; m_aLines[m_CurrentLine].m_NameColor = -2; // check for highlighted name const char *pHL = str_find_nocase(pLine, m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); if(pHL) { int Length = str_length(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || (pHL[Length] == ':' && pHL[Length+1] == ' '))) Highlighted = true; m_CompletionFav = ClientID; } m_aLines[m_CurrentLine].m_Highlighted = Highlighted; if(ClientID == -1) // server message { str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName)); str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), "%s", pLine); } else { if(m_pClient->m_aClients[ClientID].m_Team == TEAM_SPECTATORS) m_aLines[m_CurrentLine].m_NameColor = TEAM_SPECTATORS; if(m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS) { if(m_pClient->m_aClients[ClientID].m_Team == TEAM_RED) m_aLines[m_CurrentLine].m_NameColor = TEAM_RED; else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE) m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE; } str_format(m_aLines[m_CurrentLine].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName), "%2d: %s", ClientID, m_pClient->m_aClients[ClientID].m_aName); str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), ": %s", pLine); } char aBuf[1024]; str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, m_aLines[m_CurrentLine].m_Team?"teamchat":"chat", aBuf, Highlighted); } // play sound int64 Now = time_get(); if(ClientID == -1)//.........这里部分代码省略.........
开发者ID:Mailaender,项目名称:teeworlds,代码行数:101,
示例8: ifvoid INDIMountInterface::TabPageSelected( TabBox& sender, int pageIndex ){ if ( sender == GUI->SkyChart_TabBox ) { if ( pageIndex == 0 ) // AllSky tab page { m_isAllSkyView = true; } else if ( pageIndex==1 ) // FoV tab page { double CCD_chipHeight = 2200; double CCD_chipWidth = 2750; double CCD_pixelSize = 4.54/1000; double TEL_focalLength = 700; double FoV_width = CCD_chipWidth*CCD_pixelSize / TEL_focalLength*3438/60; double FoV_height = CCD_chipHeight*CCD_pixelSize / TEL_focalLength*3438/60; double limitStarMag = 13; double ra_center = m_scopeRA*360/24; double dec_center = m_scopeDEC; // download stars NetworkTransfer transfer; IsoString url( "http://simbad.u-strasbg.fr/simbad/sim-tap/sync?request=doQuery&lang=adql&format=text&query=" ); IsoString select_stmt = m_skymap->getASDLFoVQueryString( ra_center, dec_center, FoV_width, FoV_height, limitStarMag ); Console().WriteLn( "QueryStr = " + select_stmt ); url.Append( select_stmt ); transfer.SetURL( url ); transfer.OnDownloadDataAvailable( (NetworkTransfer::download_event_handler)&INDIMountInterface::DownloadObjectCoordinates, *this ); if ( !transfer.Download() ) { Console().WriteLn( "Download failed with error '" + transfer.ErrorInformation() + "'" ); } else { Console().WriteLn( String().Format( "%d bytes downloaded @ %.3g KiB/s", transfer.BytesTransferred(), transfer.TotalSpeed() ) ); StringList lines; m_downloadedFile.Break( lines, '/n', true/*trim*/ ); m_skymap->clearFoVObjectList(); if ( lines.Length() > 0 ) { for ( size_t i = 0; i < lines.Length(); i++ ) { if (i <= 1) continue; StringList tokens; lines[i].Break( tokens, '|', true/*trim*/ ); if ( tokens.Length() < 4 ) continue; if ( !tokens[1].IsNumeral() || !tokens[2].IsNumeral() || !tokens[3].IsNumeral() ) continue; SkyMap::object star; star.mainId = tokens[0]; star.ra = tokens[1].ToDouble(); star.dec = tokens[2].ToDouble(); star.v = tokens[3].ToDouble(); if ( tokens.Length() == 6 ) star.spType = tokens[5];#if DEBUG Console().WriteLn( IsoString().Format( "star=%s, ra=%f, dec=%f", star.mainId.c_str(), star.ra, star.dec ) );#endif m_skymap->addObjectToFoV( star ); } } } m_downloadedFile.Clear(); m_isAllSkyView = false; } }}
开发者ID:eprimucci,项目名称:PCL,代码行数:73,
示例9: urlvoid INDIMountInterface::ComboItemSelected( ComboBox& sender, int itemIndex ){ if ( sender == GUI->MountDevice_Combo ) { m_Device = sender.ItemText( itemIndex ); if ( TheINDIDeviceControllerInterface != nullptr ) { INDIDeviceControllerInstance* pInstance = &TheINDIDeviceControllerInterface->instance; if ( pInstance == nullptr ) return; // Start update timer GUI->UpdateMount_Timer.Start(); } pcl::Sleep( 2 ); // Download stars from simbad database NetworkTransfer transfer; IsoString url( "http://simbad.u-strasbg.fr/simbad/sim-tap/sync?request=doQuery&lang=adql&format=text&query=" ); //IsoString url( "http://simbad.cfa.harvard.edu/simbad/sim-tap/sync?request=doQuery&lang=adql&format=text&query=" ); SkyMap::geoCoord geoCoord; geoCoord.geo_lat = m_geoLat; SkyMap::filter filter; filter.dec_lowerLimit = (m_geoLat < 0) ? 90.0 - m_geoLat : m_geoLat - 90.0; filter.dec_upperLimit = (m_geoLat < 0) ? -90.0 : 90.0; filter.v_upperLimit = m_limitStarMag; m_skymap = new SkyMap( filter, geoCoord ); IsoString select_stmt = m_skymap->getASDLQueryString(); Console().WriteLn( "QueryStr = " + m_skymap->getASDLQueryString() ); url.Append( select_stmt ); transfer.SetURL( url ); transfer.OnDownloadDataAvailable( (NetworkTransfer::download_event_handler) &INDIMountInterface::DownloadObjectCoordinates, *this ); if ( !transfer.Download() ) { Console().WriteLn( "Download failed with error '" + transfer.ErrorInformation() + "'" ); if ( transfer.WasAborted() ) Console().WriteLn( "Download was aborted" ); } else { Console().WriteLn( String().Format( "%u bytes downloaded @ %.3g KiB/s", transfer.BytesTransferred(), transfer.TotalSpeed() ) ); StringList lines; m_downloadedFile.Break( lines, '/n', true/*trim*/ ); Console().WriteLn( m_downloadedFile.c_str() ); for ( size_t i = 0; i < lines.Length(); i++ ) { if ( i <= 1 ) continue; StringList tokens; lines[i].Break( tokens, '|', true/*trim*/ ); if ( tokens.Length() != 5 ) continue; if ( !tokens[1].IsNumeral() || !tokens[2].IsNumeral() || !tokens[3].IsNumeral() ) continue; SkyMap::object star; star.mainId = tokens[0]; star.ra = tokens[1].ToDouble(); star.dec = tokens[2].ToDouble(); star.v = tokens[3].ToDouble(); star.spType = tokens[4];#if DEBUG Console().WriteLn( IsoString().Format( "star=%s, ra=%f, dec=%f, vmag=%f, sp=%s", star.mainId.c_str(), star.ra, star.dec, star.v, star.spType.c_str() ) );#endif m_skymap->addObject( star ); } } m_downloadedFile.Clear(); }}
开发者ID:eprimucci,项目名称:PCL,代码行数:75,
示例10: ShowHelpstatic void ShowHelp(){ Console().Write("<raw>""Usage: ColorManagementSetup [<arg_list>]""/n""/n-enable""/n""/n Globally enable color management.""/n""/n-disable""/n""/n Globally disable color management.""/n""/n-rgb-profile=<profile_id>""/n""/n Sets the default ICC profile that will be used for RGB color images.""/n <profile_id> must correspond to an installed RGB profile.""/n (default = the current monitor profile)""/n""/n-grayscale-profile=<profile_id>""/n""/n Sets the default ICC profile that will be used for grayscale images.""/n <profile_id> must correspond to an installed RGB or grayscale profile.""/n (default = the current monitor profile)""/n""/n-rendering-intent=<intent>""/n""/n <intent> is a rendering intent to use in screen color management""/n transformations. Possible values for <intent> are:""/n""/n perceptual, saturation, relative, absolute""/n""/n which correspond to the standard perceptual, saturation, relative""/n colorimetric and absolute colorimetric rendering intents, respectively.""/n (default=perceptual)""/n""/n-on-profile-mismatch=<policy>""/n""/n <policy> identifies a profile mismatch policy. Valid policies are:""/n""/n ask : Ask the user what to do.""/n keep : Keep mismatching embedded profiles. (default=keep)""/n convert : Convert pixel values to the default profile.""/n discard : Ignore mismatching profile and leave image untagged.""/n disable : Disable color management for mismatching images.""/n""/n-on-missing-profile=<policy>""/n""/n <policy> identifies a missing profile policy. Valid policies are:""/n""/n ask : Ask the user what to do.""/n default : Assign the default profile.""/n ignore : Leave the image untagged. (default=ignore)""/n disable : Disable color management for untagged images.""/n""/n-proofing-profile=<profile_id>""/n""/n Sets the soft-proofing ICC profile. <profile_id> can be any""/n installed profile. (default = the current monitor profile)""/n""/n-proofing-intent=<intent>""/n""/n <intent> is a rendering intent used for soft-proofing color management""/n transformations. See the -rendering-intent argument for possible""/n values of <intent>. (default=relative)""/n""/n-proofing-bpc[+|-]""/n""/n Enables or disables black point compensation for proofing color""/n management transformations. (default=enabled)""/n""/n-gamut-warning-color=<css_color>""/n""/n Specifies a RGB color that will be used as the global gamut warning""/n color (for representation of out-of-gamut pixel values on images with""/n active proofing). <css_color> is a valid CSS color value; it can be""/n either an hex-encoded value in the #RRGGBB or #RRGGBBAA formats, or a""/n valid CSS color name such as /"white/", /"black/", /"red/", and so on.""/n (default=#A9A9A9)""/n""/n-default-proofing[+|-]""/n""/n Enables or disables color proofing for newly created and just opened""/n images. (default=disabled)""/n""/n-default-gamut-check[+|-]""/n""/n Enables or disables the gamut check feature for newly created and just""/n opened images. Note that gamut check only works when proofing is""/n enabled for a particular image. (default=disabled)""/n""/n-embed-rgb[+|-]""/n-embed-grayscale[+|-]""/n""/n Enables or disables default profile embedding in written image files,""/n for RGB color and grayscale images, respectively. Note that each file""/n format may have its own profile embedding preferences; these are only""/n default settings.""/n"//.........这里部分代码省略.........
开发者ID:AndresPozo,项目名称:PCL,代码行数:101,
示例11: gvoid INDIMountInterface::SkyChart_Paint( Control& sender, const Rect& updateRect ){ Graphics g( sender ); RGBA darkRed = RGBAColor( 153, 0, 0 ); RGBA darkYellow = RGBAColor( 153, 153, 0 ); RGBA darkGreen = RGBAColor( 0, 153, 0 ); Rect r( sender.BoundsRect() ); int w = r.Width(); int h = r.Height(); int x0 = w >> 1; int y0 = h >> 1; g.FillRect( r, 0u ); g.SetBrush( Brush::Null() ); g.SetPen( darkRed ); const int margin = 10; g.DrawLine( x0, 0+margin, x0, h-margin ); g.DrawLine( 0+margin, y0, w-margin, y0 ); g.EnableAntialiasing(); if ( m_isAllSkyView ) { double chartRadius = x0 - margin; g.DrawCircle( x0, y0, chartRadius ); // draw telescope position StereoProjection::Spherical s; double hourAngle = (m_TargetRA.ToDouble() - m_lst)*360/24; double currentAlt = SkyMap::getObjectAltitude( m_TargetDEC.ToDouble(), hourAngle, m_geoLat ); double currentAz = SkyMap::getObjectAzimut( m_TargetDEC.ToDouble(), hourAngle, m_geoLat ); s.phi = Rad( currentAz ); s.theta = Rad( 90 + currentAlt ); StereoProjection::Polar p = s.Projected( chartRadius ); StereoProjection::Rectangular r = p.ToRectangular();#if 0 Console().WriteLn( String().Format( "x=%f, y=%f, r=%f", r.x, r.y, chartRadius ) ); Console().WriteLn( String().Format( "x0=%d, y0=%d", x0, y0 ) ); Console().WriteLn( String().Format( "w=%d, h=%d", w, h ) ); Console().WriteLn( String().Format( "phi=%f, theta=%f", s.phi, s.theta ) ); Console().WriteLn( String().Format( "r=%f, pphi=%f", p.r, p.phi ) );#endif g.DrawCircle( x0+r.x, y0+r.y, 5 ); g.SetPen( darkGreen ); hourAngle = (m_scopeRA - m_lst)*360/24; currentAlt = SkyMap::getObjectAltitude( m_scopeDEC, hourAngle, m_geoLat ); currentAz = SkyMap::getObjectAzimut( m_scopeDEC, hourAngle, m_geoLat ); s.phi = Rad( currentAz ); s.theta = Rad( 90 + currentAlt ); r = s.Projected( chartRadius ).ToRectangular(); g.DrawCircle( x0+r.x, y0+r.y, 5 ); g.SetPen( darkYellow ); if ( m_skymap != nullptr ) m_skymap->plotStars( m_lst, m_geoLat, x0, y0, chartRadius, g, m_limitStarMag ); } else { if ( m_skymap != nullptr ) { double CCD_chipHeight = 2200; double CCD_chipWidth = 2750; double CCD_pixelSize = 4.54/1000; double TEL_focalLength = 700; double FoV_width = CCD_chipWidth*CCD_pixelSize / TEL_focalLength*3438/60; double FoV_height = CCD_chipHeight*CCD_pixelSize / TEL_focalLength*3438/60; double scale = 180.0/FoV_width; // draw scope position double currentAlt = SkyMap::getObjectAltitude( m_scopeDEC, m_scopeRA*360/24, m_geoLat ); double currentAz = SkyMap::getObjectAzimut( m_scopeDEC, m_scopeRA*360/24, m_geoLat ); StereoProjection::Spherical spherical( Rad( currentAz ), Rad( 90 + currentAlt ) ); StereoProjection::Polar p = spherical.Projected( scale*x0 ); StereoProjection::Rectangular r = p.ToRectangular(); //Console().WriteLn( String().Format( "xx=%f, yy=%f, r=%f", r.x, r.y, scale * x0 ) ); g.DrawCircle( x0, y0, 5 ); // draw alignment deviation double alignAlt = SkyMap::getObjectAltitude( m_alignedDEC, m_alignedRA*360/24, m_geoLat ); double alignAz = SkyMap::getObjectAzimut( m_alignedDEC, m_alignedRA*360/24, m_geoLat ); StereoProjection::Rectangular rAlign = StereoProjection::Spherical( Rad( alignAz ), Rad( 90 + alignAlt ) ).Projected( scale*x0 ).ToRectangular(); g.SetPen( darkGreen ); g.DrawLine( x0 - r.x + r.x, y0 - r.y + r.y, x0 - r.x + rAlign.x, y0 - r.y + rAlign.y ); m_skymap->plotFoVStars( m_lst, m_geoLat, x0-r.x, y0-r.y, scale*x0, g, 13 ); } }}
开发者ID:eprimucci,项目名称:PCL,代码行数:99,
示例12: Consolevoid CControls::OnConsoleInit(){ // game commands Console()->Register("+left", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputDirectionLeft, "Move left"); Console()->Register("+right", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputDirectionRight, "Move right"); Console()->Register("+jump", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputData.m_Jump, "Jump"); Console()->Register("+hook", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputData.m_Hook, "Hook"); Console()->Register("+fire", "", CFGFLAG_CLIENT, ConKeyInputCounter, &m_InputData.m_Fire, "Fire"); { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 1}; Console()->Register("+weapon1", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to hammer"); } { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 2}; Console()->Register("+weapon2", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to gun"); } { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 3}; Console()->Register("+weapon3", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to shotgun"); } { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 4}; Console()->Register("+weapon4", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to grenade"); } { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 5}; Console()->Register("+weapon5", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to rifle"); } { static CInputSet s_Set = {this, &m_InputData.m_NextWeapon, 0}; Console()->Register("+nextweapon", "", CFGFLAG_CLIENT, ConKeyInputNextPrevWeapon, (void *)&s_Set, "Switch to next weapon"); } { static CInputSet s_Set = {this, &m_InputData.m_PrevWeapon, 0}; Console()->Register("+prevweapon", "", CFGFLAG_CLIENT, ConKeyInputNextPrevWeapon, (void *)&s_Set, "Switch to previous weapon"); }}
开发者ID:chi1,项目名称:twmaps,代码行数:18,
示例13: widthvoid SaveScreen::Resize(int NewX,int NewY, DWORD Corner, bool SyncWithConsole)// Corner definition:// 0 --- 1// | |// 2 --- 3{ const auto OWi = width(); const auto OHe = height(); int iY = 0; if (OWi==NewX && OHe==NewY) { return; } int NX1 = 0, NX2 = 0, NY1 = 0, NY2 = 0; matrix<FAR_CHAR_INFO> NewBuf(NewY, NewX); CleanupBuffer(NewBuf.data(), NewBuf.size()); const auto NewWidth = std::min(OWi, NewX); const auto NewHeight = std::min(OHe, NewY); int iYReal; int ToIndex=0; int FromIndex=0; if (Corner & 2) { NY2 = m_Y1 + NewY - 1; NY1 = NY2 - NewY + 1; } else { NY1 = m_Y1; NY2 = NY1 + NewY - 1; } if (Corner & 1) { NX2 = m_X1 + NewX - 1; NX1 = NX2 - NewX + 1; } else { NX1 = m_X1; NX2 = NX1 + NewX - 1; } for (iY=0; iY<NewHeight; iY++) { if (Corner & 2) { if (OHe>NewY) { iYReal=OHe-NewY+iY; FromIndex=iYReal*OWi; ToIndex=iY*NewX; } else { iYReal=NewY-OHe+iY; ToIndex=iYReal*NewX; FromIndex=iY*OWi; } } if (Corner & 1) { if (OWi>NewX) { FromIndex+=OWi-NewX; } else { ToIndex+=NewX-OWi; } } std::copy_n(ScreenBuf.data() + FromIndex, NewWidth, NewBuf.data() + ToIndex); } // achtung, experimental if((Corner&2) && SyncWithConsole) { Console().ResetPosition(); if(NewY!=OHe) { matrix<FAR_CHAR_INFO> Tmp(abs(OHe - NewY), std::max(NewX, OWi)); if(NewY>OHe) { SMALL_RECT ReadRegion={0, 0, static_cast<SHORT>(NewX-1), static_cast<SHORT>(NewY-OHe-1)}; Console().ReadOutput(Tmp, ReadRegion); for(size_t i = 0; i != Tmp.height(); ++i) { std::copy_n(Tmp[i].data(), Tmp.width(), NewBuf[i].data()); } } else { SMALL_RECT WriteRegion={0, static_cast<SHORT>(NewY-OHe), static_cast<SHORT>(NewX-1), -1}; for(size_t i = 0; i != Tmp.height(); ++i) { std::copy_n(ScreenBuf[i].data(), Tmp.width(), Tmp[i].data()); } Console().WriteOutput(Tmp, WriteRegion); Console().Commit();//.........这里部分代码省略.........
开发者ID:Firebie,项目名称:FarManager,代码行数:101,
示例14: Apply static void Apply( GenericImage<P>& img, const View& view, const FluxCalibrationInstance& instance ) { FITSKeywordArray inputKeywords; view.Window().GetKeywords( inputKeywords ); if ( KeywordExists( inputKeywords, "FLXMIN" ) || KeywordExists( inputKeywords, "FLXRANGE" ) || KeywordExists( inputKeywords, "FLX2DN" ) ) { throw Error( "Already calibrated image" ); } if ( img.IsColor() ) throw Error( "Can't calibrate a color image" ); float Wc = instance.p_wavelength.GetValue( inputKeywords ); float Tr = Max( 1.0F, instance.p_transmissivity.GetValue( inputKeywords ) ); float Delta = instance.p_filterWidth.GetValue( inputKeywords ); float Ap = instance.p_aperture.GetValue( inputKeywords ) / 10; // mm -> cm float Cobs = Max( 0.0F, instance.p_centralObstruction.GetValue( inputKeywords ) ) / 10; // mm -> cm float ExpT = instance.p_exposureTime.GetValue( inputKeywords ); float AtmE = Max( 0.0F, instance.p_atmosphericExtinction.GetValue( inputKeywords ) ); float G = Max( 1.0F, instance.p_sensorGain.GetValue( inputKeywords ) ); float QEff = Max( 1.0F, instance.p_quantumEfficiency.GetValue( inputKeywords ) ); if ( Wc <= 0 ) throw Error( "Invalid filter wavelength" ); if ( Tr <= 0 || Tr > 1 ) throw Error( "Invalid filter transmissivity" ); if ( Delta <= 0 ) throw Error( "Invalid filter width" ); if ( Ap <= 0 ) throw Error( "Invalid aperture" ); if ( Cobs < 0 || Cobs >= Ap ) throw Error( "Invalid central obstruction area" ); if ( ExpT <= 0 ) throw Error( "Invalid exposure time" ); if ( AtmE < 0 || AtmE >= 1 ) throw Error( "Invalid atmospheric extinction" ); if ( G <= 0 ) throw Error( "Invalid sensor gain" ); if ( QEff <= 0 || QEff > 1 ) throw Error( "Invalid quantum efficiency" ); FITSKeywordArray keywords; float pedestal = 0; bool foundPedestal = false; for ( FITSKeywordArray::const_iterator i = inputKeywords.Begin(); i != inputKeywords.End(); ++i ) if ( i->name == "PEDESTAL" ) { if ( i->value.TryToFloat( pedestal ) ) foundPedestal = true; pedestal /= 65535; // 2^16-1 maximum value of a 16bit CCD. } else keywords.Add( *i ); if ( foundPedestal ) Console().NoteLn( "<end><cbr><br>* FluxCalibration: PEDESTAL keyword found: " + view.FullId() ); // double F = Wc * inv_ch * (1 - Tr) * Delta * Ap * Cobs * ExpT * AtmE * G * QEff; double F = Wc * inv_ch * (1 - AtmE) * Delta * ( Const<double>::pi() / 4 * ( Ap*Ap - Cobs*Cobs ) ) * ExpT * Tr * G * QEff; size_type N = img.NumberOfPixels(); typename P::sample* f = img.PixelData( 0 ); const typename P::sample* fN = f + N; double flxMin = DBL_MAX; double flxMax = 0; for ( ; f < fN; ++f, ++img.Status() ) { double I; P::FromSample( I, *f ); I = (I - pedestal)/F; *f = P::ToSample( I ); if ( I < flxMin ) flxMin = I; if ( I > flxMax ) flxMax = I; } img.Rescale(); keywords.Add( FITSHeaderKeyword( "FLXMIN", IsoString().Format( "%.8e", flxMin ), "" ) ); keywords.Add( FITSHeaderKeyword( "FLXRANGE", IsoString().Format( "%.8e", flxMax - flxMin ), "FLXRANGE*pixel_value + FLXMIN = erg/cm^2/s/nm" ) ); keywords.Add( FITSHeaderKeyword( "FLX2DN", IsoString().Format( "%.8e", F*65535 ), "(FLXRANGE*pixel_value + FLXMIN)*FLX2DN = DN" ) );//.........这里部分代码省略.........
开发者ID:SunGong1993,项目名称:PCL,代码行数:101,
示例15: Getvoid CTeeFiles::Save(){ const int sz = 32; for(int i = 0; i < m_aTees.size(); i++) { CTee *pTee = Get(i); bool Rename = false; char aFilename[41]; // + ".tee" + "xxx_" char aBuf[512]; if(pTee->m_aFilename[0] == '/0') { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "teefile%d%s%s%s%d%d%d%d", i, pTee->m_aName, pTee->m_aClan, pTee->m_aSkin, pTee->m_UseCustomColor, pTee->m_ColorBody, pTee->m_ColorFeet, pTee->m_Country); str_format(aFilename, sizeof(aFilename), "%03d_%s.tee", i, md5(aBuf)); } else { if(!(str_isdigit(pTee->m_aFilename[0]) && str_isdigit(pTee->m_aFilename[1]) && str_isdigit(pTee->m_aFilename[2]) && pTee->m_aFilename[3] == '_')) { str_format(aFilename, sizeof(aFilename), "%03d_%s", i, pTee->m_aFilename); Rename = true; } else { char aNewIndex[4]; char aOldIndex[4]; str_format(aNewIndex, sizeof(aNewIndex), "%03d", i); str_format(aOldIndex, sizeof(aOldIndex), pTee->m_aFilename); str_format(aFilename, sizeof(aFilename), pTee->m_aFilename); if(str_toint(aNewIndex) != str_toint(aOldIndex)) { for(int i = 0; i < 3; i++) aFilename[i] = aNewIndex[i]; Rename = true; } } } if(Rename) { char OldName[512]; char NewName[512]; str_format(OldName, sizeof(OldName), "xclient/teefiles/%s", pTee->m_aFilename); str_format(NewName, sizeof(NewName), "xclient/teefiles/%s", aFilename); Storage()->RenameFile(OldName, NewName, IStorage::TYPE_SAVE); Storage()->RemoveFile(OldName, IStorage::TYPE_SAVE); str_format(aBuf, sizeof(aBuf), "renamed '%s' to %s", pTee->m_aFilename, aFilename); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf); } str_format(aBuf, sizeof(aBuf), "xclient/teefiles/%s", aFilename); IOHANDLE File = Storage()->OpenFile(aBuf, IOFLAG_WRITE, IStorage::TYPE_SAVE); if(!File) continue; char aTeeEntry[NUM_TEE_ENTRIES][sz]; str_format(aTeeEntry[TEE_NAME], sz, pTee->m_aName); str_format(aTeeEntry[TEE_CLAN], sz, pTee->m_aClan); str_format(aTeeEntry[TEE_SKIN], sz, pTee->m_aSkin); str_format(aTeeEntry[TEE_USECUSTOMCOLOR], sz, "%d", pTee->m_UseCustomColor); str_format(aTeeEntry[TEE_COLORBODY], sz, "%d", pTee->m_ColorBody); str_format(aTeeEntry[TEE_COLORFEET], sz, "%d", pTee->m_ColorFeet); str_format(aTeeEntry[TEE_COUNTRY], sz, "%d", pTee->m_Country); for(int j = 0; j < NUM_TEE_ENTRIES; j++) { if(!File) { str_format(aBuf, sizeof(aBuf), "failed to save '%s' at line %d", aFilename, j); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf); io_close(File); mem_zero(aTeeEntry[j], sizeof(aTeeEntry[j])); break; } io_write(File, aTeeEntry[j], str_length(aTeeEntry[j])); io_write_newline(File); } io_close(File); } }
开发者ID:MichelFR,项目名称:Teeworlds-Bot,代码行数:83,
示例16: LOGDGLE_RESULT CHookedWindow::InitWindow(TWindowHandle tHandle, const TCrRndrInitResults &stRndrInitResults, TProcDelegate *pDelMainLoop, TMsgProcDelegate *pDelMsgProc){ if(_stOldWindowProc || _stOldRootWindowProc) return E_FAIL; _hWnd = tHandle; _pDelMainLoop = pDelMainLoop; _pDelMessageProc = pDelMsgProc; _bNoMloopHook = (Core()->EngWindow()->uiFlags & EWF_DONT_HOOK_MAIN_LOOP) != 0; if (IsWindow(tHandle) == FALSE) { LOG("Received HWND is not window based control handle.", LT_FATAL); return E_INVALIDARG; } _hRootHWnd = GetAncestor(_hWnd, GA_ROOT); if (_hRootHWnd == NULL) LOG("Can't get root window handle.", LT_ERROR); else { if (_hRootHWnd == _hWnd) { LOG("Engine can't be assigned to the root window.", LT_FATAL); return E_INVALIDARG; } if (Core()->EngWindow()->uiFlags & EWF_DONT_HOOK_ROOT_WINDOW) _stOldRootWindowProc = NULL; else { _stOldRootWindowProc = (WNDPROC)SetWindowLongPtr(_hRootHWnd, GWLP_WNDPROC, (LONG_PTR)_s_RootWindowProc); if (_stOldRootWindowProc == NULL) LOG("Failed to set root window message hook.", LT_ERROR); else { SetWindowLongPtr(_hRootHWnd, GWLP_USERDATA, (LONG_PTR)this); Console()->RegComProc("quit", "Closes owner root window, quits engine and releases all resources.", &_s_ConsoleQuit, (void*)this); } } } _stOldWindowProc = (WNDPROC)SetWindowLongPtr(_hWnd, GWLP_WNDPROC, (LONG_PTR)_s_WindowProc); if (_stOldWindowProc != NULL) { SetWindowLongPtr(_hWnd, GWLP_USERDATA, (LONG_PTR)this); LOG("Window control message hook has been set successfully.", LT_INFO); if (!(_hDC = GetDC(_hWnd))) { LOG("Can't get window Draw Context.", LT_FATAL); return E_FAIL; } return S_OK; } else { LOG("Failed to set window control message hook.", LT_ERROR); return E_FAIL; }}
开发者ID:whztt07,项目名称:DGLE,代码行数:67,
示例17: Consolevoid CMapLayers::OnConsoleInit(){ Console()->Chain("cl_menu_map", ConchainBackgroundMap, this); Console()->Chain("cl_show_menu_map", ConchainBackgroundMap, this);}
开发者ID:Redix,项目名称:teeworlds,代码行数:5,
示例18: whilevoid CChat::AddLine(int ClientID, int Team, const char *pLine){ if(*pLine == 0 || (ClientID != -1 && (m_pClient->m_aClients[ClientID].m_aName[0] == '/0' || // unknown client m_pClient->m_aClients[ClientID].m_ChatIgnore || (m_pClient->m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend)))) return; bool Highlighted = false; char *p = const_cast<char*>(pLine); while(*p) { Highlighted = false; pLine = p; // find line seperator and strip multiline while(*p) { if(*p++ == '/n') { *(p-1) = 0; break; } } m_CurrentLine = (m_CurrentLine+1)%MAX_LINES; m_aLines[m_CurrentLine].m_Time = time_get(); m_aLines[m_CurrentLine].m_YOffset[0] = -1.0f; m_aLines[m_CurrentLine].m_YOffset[1] = -1.0f; m_aLines[m_CurrentLine].m_ClientID = ClientID; m_aLines[m_CurrentLine].m_Team = Team; m_aLines[m_CurrentLine].m_NameColor = -2; // check for highlighted name const char *pHL = str_find_nocase(pLine, m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); if(pHL) { int Length = str_length(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || (pHL[Length] == ':' && pHL[Length+1] == ' '))) Highlighted = true; } m_aLines[m_CurrentLine].m_Highlighted = Highlighted; if(ClientID == -1) // server message { str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName)); str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), "%s", pLine); } else { if(m_pClient->m_aClients[ClientID].m_Team == TEAM_SPECTATORS) m_aLines[m_CurrentLine].m_NameColor = TEAM_SPECTATORS; if(m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS) { if(m_pClient->m_aClients[ClientID].m_Team == TEAM_RED) m_aLines[m_CurrentLine].m_NameColor = TEAM_RED; else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE) m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE; } str_copy(m_aLines[m_CurrentLine].m_aName, m_pClient->m_aClients[ClientID].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName)); str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), ": %s", pLine); } char aBuf[1024]; str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, m_aLines[m_CurrentLine].m_Team?"teamchat":"chat", aBuf); } // play sound int64 Now = time_get(); if(ClientID == -1) { if(Now-m_aLastSoundPlayed[CHAT_SERVER] >= time_freq()*3/10) { m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0); m_aLastSoundPlayed[CHAT_SERVER] = Now; } } else if(Highlighted) { if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10) { m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now; } } else { if(Now-m_aLastSoundPlayed[CHAT_CLIENT] >= time_freq()*3/10) { m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); m_aLastSoundPlayed[CHAT_CLIENT] = Now; } }}
开发者ID:VoidFenix,项目名称:teeworlds,代码行数:95,
示例19: Consolevoid CScoreboard::OnConsoleInit(){ Console()->Register("+scoreboard", "", CFGFLAG_CLIENT, ConKeyScoreboard, this, "Show scoreboard");}
开发者ID:Parhamic,项目名称:teeworlds,代码行数:4,
示例20: lockbool RotationInstance::ExecuteOn( View& view ){ if ( !view.IsMainView() ) return false; // should never reach this point! AutoViewLock lock( view ); ImageVariant image = view.Image(); if ( image.IsComplexSample() ) return false; double degrees = Round( Deg( p_angle ), 4 ); if ( degrees == 0 ) { Console().WriteLn( "<end><cbr><* Identity *>" ); return true; } ImageWindow window = view.Window(); window.RemoveMaskReferences(); window.RemoveMask(); window.DeletePreviews(); Console().EnableAbort(); StandardStatus status; image.SetStatusCallback( &status ); if ( p_optimizeFast ) switch ( TruncI( degrees ) ) { case 90: Rotate90CCW() >> image; return true; case -90: Rotate90CW() >> image; return true; case 180: case -180: Rotate180() >> image; return true; default: break; } AutoPointer<PixelInterpolation> interpolation( NewInterpolation( p_interpolation, 1, 1, 1, 1, true, p_clampingThreshold, p_smoothness, image ) ); Rotation T( *interpolation, p_angle ); /* * On 32-bit systems, make sure the resulting image requires less than 4 GB. */ if ( sizeof( void* ) == sizeof( uint32 ) ) { int width = image.Width(), height = image.Height(); T.GetNewSizes( width, height ); uint64 sz = uint64( width )*uint64( height )*image.NumberOfChannels()*image.BytesPerSample(); if ( sz > uint64( uint32_max-256 ) ) throw Error( "Rotation: Invalid operation: Target image dimensions would exceed four gigabytes" ); } T.SetFillValues( p_fillColor ); T >> image; return true;}
开发者ID:SunGong1993,项目名称:PCL,代码行数:69,
示例21: Consolevoid CInfoPanel::OnConsoleInit(){ Console()->Register("infomsg", "r", CFGFLAG_CLIENT, ConInfoMsg, this, "Show message on info panel");}
开发者ID:kaddyd,项目名称:teeworlds,代码行数:4,
示例22: Kernelvoid CGameClient::OnConsoleInit(){ m_pClient = Kernel()->RequestInterface<IClient>(); m_pGraphics = Kernel()->RequestInterface<IGraphics>(); m_pTextRender = Kernel()->RequestInterface<ITextRender>(); m_pSound = Kernel()->RequestInterface<ISound>(); m_pInput = Kernel()->RequestInterface<IInput>(); m_pConsole = Kernel()->RequestInterface<IConsole>(); m_pStorage = Kernel()->RequestInterface<IStorage>(); m_pDemoPlayer = Kernel()->RequestInterface<IDemoPlayer>(); m_pServerBrowser = Kernel()->RequestInterface<IServerBrowser>(); // setup pointers m_pBinds = &::gs_Binds; m_pGameConsole = &::gs_GameConsole; m_pParticles = &::gs_Particles; m_pMenus = &::gs_Menus; m_pSkins = &::gs_Skins; m_pChat = &::gs_Chat; m_pFlow = &::gs_Flow; m_pCamera = &::gs_Camera; m_pControls = &::gs_Controls; m_pEffects = &::gs_Effects; m_pSounds = &::gs_Sounds; m_pMotd = &::gs_Motd; m_pDamageind = &::gsDamageInd; m_pMapimages = &::gs_MapImages; m_pVoting = &::gs_Voting; // make a list of all the systems, make sure to add them in the corrent render order m_All.Add(m_pSkins); m_All.Add(m_pMapimages); m_All.Add(m_pEffects); // doesn't render anything, just updates effects m_All.Add(m_pParticles); m_All.Add(m_pBinds); m_All.Add(m_pControls); m_All.Add(m_pCamera); m_All.Add(m_pSounds); m_All.Add(m_pVoting); m_All.Add(m_pParticles); // doesn't render anything, just updates all the particles m_All.Add(&gs_MapLayersBackGround); // first to render m_All.Add(&m_pParticles->m_RenderTrail); m_All.Add(&m_pParticles->m_RenderExplosions); m_All.Add(&gs_Items); m_All.Add(&gs_Players); m_All.Add(&gs_MapLayersForeGround); m_All.Add(&gs_NamePlates); m_All.Add(&m_pParticles->m_RenderGeneral); m_All.Add(m_pDamageind); m_All.Add(&gs_Hud); m_All.Add(&gs_Emoticon); m_All.Add(&gs_KillMessages); m_All.Add(m_pChat); m_All.Add(&gs_Broadcast); m_All.Add(&gs_DebugHud); m_All.Add(&gs_Scoreboard); m_All.Add(m_pMotd); m_All.Add(m_pMenus); m_All.Add(m_pGameConsole); // build the input stack m_Input.Add(&m_pMenus->m_Binder); // this will take over all input when we want to bind a key m_Input.Add(&m_pBinds->m_SpecialBinds); m_Input.Add(m_pGameConsole); m_Input.Add(m_pChat); // chat has higher prio due to tha you can quit it by pressing esc m_Input.Add(m_pMotd); // for pressing esc to remove it m_Input.Add(m_pMenus); m_Input.Add(&gs_Emoticon); m_Input.Add(m_pControls); m_Input.Add(m_pBinds); // add the some console commands Console()->Register("team", "i", CFGFLAG_CLIENT, ConTeam, this, "Switch team"); Console()->Register("kill", "", CFGFLAG_CLIENT, ConKill, this, "Kill yourself"); // register server dummy commands for tab completion Console()->Register("tune", "si", CFGFLAG_SERVER, ConServerDummy, 0, "Tune variable to value"); Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConServerDummy, 0, "Reset tuning"); Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConServerDummy, 0, "Dump tuning"); Console()->Register("change_map", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Change map"); Console()->Register("restart", "?i", CFGFLAG_SERVER, ConServerDummy, 0, "Restart in x seconds"); Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Broadcast message"); //MACRO_REGISTER_COMMAND("say", "r", CFGFLAG_SERVER, con_serverdummy, 0); Console()->Register("set_team", "ii", CFGFLAG_SERVER, ConServerDummy, 0, "Set team of player to team"); Console()->Register("addvote", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Add a voting option"); //MACRO_REGISTER_COMMAND("vote", "", CFGFLAG_SERVER, con_serverdummy, 0); // propagate pointers m_UI.SetGraphics(Graphics(), TextRender()); m_RenderTools.m_pGraphics = Graphics(); m_RenderTools.m_pUI = UI(); for(int i = 0; i < m_All.m_Num; i++) m_All.m_paComponents[i]->m_pClient = this; // let all the other components register their console commands for(int i = 0; i < m_All.m_Num; i++) m_All.m_paComponents[i]->OnConsoleInit();//.........这里部分代码省略.........
开发者ID:magnet,项目名称:teeworlds,代码行数:101,
示例23: Console/** * * Returns an instance of Console for use in debugging. This uses /dev/stdout * * @return The Console instance */Console Console::debug(){ return Console("debug", &std::cout);}
开发者ID:curquhart,项目名称:rsql-backend,代码行数:10,
示例24: DebugBreakvoid CArchonProcess::Run (void)// Run//// This thread will start all engines and continue running// until all engines stop. { int i; if (m_bDebugger) DebugBreak(); // If we could not boot properly, then we stop if (m_iState == stateBootError) return; // Set event indicating that thread should run m_RunEvent.Set(); // Start some threads m_ImportThread.Start(); // Start all engines. At this point we have multiple threads // potentially calling on the IArchonProcessCtx interface // // This allows the engines to start at least one thread. // LATER: Catch errors. for (i = 0; i < m_Engines.GetCount(); i++) m_Engines[i].pEngine->StartRunning(m_RunEvent, m_PauseEvent, m_QuitEvent); // Do stuff now that the module has started OnModuleStart(); // At this point it is safe to call the logging system if (m_bCentralModule) Log(MSG_LOG_INFO, STR_CENTRAL_MODULE_STARTED); else if (!m_bConsoleMode) Log(MSG_LOG_INFO, STR_BOOT_COMPLETE); // If we've in console mode, then run the input loop. CConsoleThread Console(this); if (m_bConsoleMode) Console.Start(); // Loop until we quit. We stop every so often to do clean up // tasks such as garbage collection. CWaitArray Wait; int QUIT_SIGNAL = Wait.Insert(m_QuitSignalEvent); while (true) { int iEvent = Wait.WaitForAny(15000); if (iEvent == QUIT_SIGNAL) break; else if (iEvent == OS_WAIT_TIMEOUT) { if (m_bConsoleMode) Console.OnStartHousekeeping(); CollectGarbage(); SendGlobalMessage(MSG_ARC_HOUSEKEEPING); if (m_bConsoleMode) Console.OnEndHousekeeping(); } } // Some engines still need an explicit call (because they don't have // their own main thread). for (i = 0; i < m_Engines.GetCount(); i++) m_Engines[i].pEngine->SignalShutdown(); // Signal the engines to quit m_QuitEvent.Set(); // We wait until all engines have been shut down for (i = 0; i < m_Engines.GetCount(); i++) m_Engines[i].pEngine->WaitForShutdown(); // Done Shutdown(); }
开发者ID:kronosaur,项目名称:Hexarc,代码行数:95,
示例25: str_copy//.........这里部分代码省略......... // skip packets that are old if(IntendedTick > m_aClients[ClientId].m_LastInputTick) { int TimeLeft = ((TickStartTime(IntendedTick)-time_get())*1000) / time_freq(); CMsgPacker Msg(NETMSG_INPUTTIMING); Msg.AddInt(IntendedTick); Msg.AddInt(TimeLeft); SendMsgEx(&Msg, 0, ClientId, true); } m_aClients[ClientId].m_LastInputTick = IntendedTick; pInput = &m_aClients[ClientId].m_aInputs[m_aClients[ClientId].m_CurrentInput]; if(IntendedTick <= Tick()) IntendedTick = Tick()+1; pInput->m_GameTick = IntendedTick; for(int i = 0; i < Size/4; i++) pInput->m_aData[i] = Unpacker.GetInt(); mem_copy(m_aClients[ClientId].m_LatestInput.m_aData, pInput->m_aData, MAX_INPUT_SIZE*sizeof(int)); m_aClients[ClientId].m_CurrentInput++; m_aClients[ClientId].m_CurrentInput %= 200; // call the mod with the fresh input data if(m_aClients[ClientId].m_State == CClient::STATE_INGAME) GameServer()->OnClientDirectInput(ClientId, m_aClients[ClientId].m_LatestInput.m_aData); } else if(Msg == NETMSG_RCON_CMD) { const char *pCmd = Unpacker.GetString(); if(Unpacker.Error() == 0 && m_aClients[ClientId].m_Authed) { dbg_msg("server", "ClientId=%d rcon='%s'", ClientId, pCmd); Console()->ExecuteLine(pCmd); } } else if(Msg == NETMSG_RCON_AUTH) { const char *pPw; Unpacker.GetString(); // login name, not used pPw = Unpacker.GetString(); if(Unpacker.Error() == 0) { if(g_Config.m_SvRconPassword[0] == 0) { SendRconLine(ClientId, "No rcon password set on server. Set sv_rcon_password to enable the remote console."); } else if(str_comp(pPw, g_Config.m_SvRconPassword) == 0) { CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS); Msg.AddInt(1); SendMsgEx(&Msg, MSGFLAG_VITAL, ClientId, true); m_aClients[ClientId].m_Authed = 1; SendRconLine(ClientId, "Authentication successful. Remote console access granted."); dbg_msg("server", "ClientId=%d authed", ClientId); } else { SendRconLine(ClientId, "Wrong password."); } } } else if(Msg == NETMSG_PING) { CMsgPacker Msg(NETMSG_PING_REPLY); SendMsgEx(&Msg, 0, ClientId, true); } else { char aHex[] = "0123456789ABCDEF"; char aBuf[512]; for(int b = 0; b < pPacket->m_DataSize && b < 32; b++) { aBuf[b*3] = aHex[((const unsigned char *)pPacket->m_pData)[b]>>4]; aBuf[b*3+1] = aHex[((const unsigned char *)pPacket->m_pData)[b]&0xf]; aBuf[b*3+2] = ' '; aBuf[b*3+3] = 0; } dbg_msg("server", "strange message ClientId=%d msg=%d data_size=%d", ClientId, Msg, pPacket->m_DataSize); dbg_msg("server", "%s", aBuf); } } else { // game message if(m_aClients[ClientId].m_State >= CClient::STATE_READY) GameServer()->OnMessage(Msg, &Unpacker, ClientId); } }
开发者ID:ddup1,项目名称:teeworlds,代码行数:101,
示例26: Consolevoid CCamera::OnConsoleInit(){ Console()->Register("set_position", "iii", CFGFLAG_CLIENT, ConSetPosition, this, "Sets the rotation position");}
开发者ID:4a4ik,项目名称:teeworlds,代码行数:4,
示例27: ifvoid CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker){ // special messages if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE) { int Num = pUnpacker->GetInt(); for(int k = 0; k < Num; k++) { CNetObj_Projectile Proj; for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++) ((int *)&Proj)[i] = pUnpacker->GetInt(); if(pUnpacker->Error()) return; g_GameClient.m_pItems->AddExtraProjectile(&Proj); } return; } else if(MsgId == NETMSGTYPE_SV_TUNEPARAMS) { // unpack the new tuning CTuningParams NewTuning; int *pParams = (int *)&NewTuning; for(unsigned i = 0; i < sizeof(CTuningParams)/sizeof(int); i++) pParams[i] = pUnpacker->GetInt(); // check for unpacking errors if(pUnpacker->Error()) return; m_ServerMode = SERVERMODE_PURE; // apply new tuning m_Tuning = NewTuning; return; } void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker); if(!pRawMsg) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn()); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", aBuf); return; } // TODO: this should be done smarter for(int i = 0; i < m_All.m_Num; i++) m_All.m_paComponents[i]->OnMessage(MsgId, pRawMsg); if(MsgId == NETMSGTYPE_SV_READYTOENTER) { Client()->EnterGame(); } else if (MsgId == NETMSGTYPE_SV_EMOTICON) { CNetMsg_Sv_Emoticon *pMsg = (CNetMsg_Sv_Emoticon *)pRawMsg; // apply m_aClients[pMsg->m_ClientID].m_Emoticon = pMsg->m_Emoticon; m_aClients[pMsg->m_ClientID].m_EmoticonStart = Client()->GameTick(); } else if(MsgId == NETMSGTYPE_SV_SOUNDGLOBAL) { if(m_SuppressEvents) return; // don't enqueue pseudo-global sounds from demos (created by PlayAndRecord) CNetMsg_Sv_SoundGlobal *pMsg = (CNetMsg_Sv_SoundGlobal *)pRawMsg; if(pMsg->m_SoundID == SOUND_CTF_DROP || pMsg->m_SoundID == SOUND_CTF_RETURN || pMsg->m_SoundID == SOUND_CTF_CAPTURE || pMsg->m_SoundID == SOUND_CTF_GRAB_EN || pMsg->m_SoundID == SOUND_CTF_GRAB_PL) g_GameClient.m_pSounds->Enqueue(CSounds::CHN_GLOBAL, pMsg->m_SoundID); else g_GameClient.m_pSounds->Play(CSounds::CHN_GLOBAL, pMsg->m_SoundID, 1.0f, vec2(0,0)); }}
开发者ID:Milkax3,项目名称:TRP--TeeRolePlay-,代码行数:80,
示例28: ConsoleCRender3D::~CRender3D(){ Console()->UnRegCom("rnd3d_profiler"); Console()->UnRegCom("rnd3d_draw_axes"); Console()->UnRegCom("rnd3d_draw_lights");}
开发者ID:whztt07,项目名称:DGLE,代码行数:6,
示例29: Collision//.........这里部分代码省略......... for(int i = 0; i < MAX_CLIENTS; i++) { if(!m_Snap.m_aCharacters[i].m_Active) continue; g_GameClient.m_aClients[i].m_Predicted.Init(&World, Collision()); World.m_apCharacters[i] = &g_GameClient.m_aClients[i].m_Predicted; g_GameClient.m_aClients[i].m_Predicted.Read(&m_Snap.m_aCharacters[i].m_Cur); } // predict for(int Tick = Client()->GameTick()+1; Tick <= Client()->PredGameTick(); Tick++) { // fetch the local if(Tick == Client()->PredGameTick() && World.m_apCharacters[m_Snap.m_LocalClientID]) m_PredictedPrevChar = *World.m_apCharacters[m_Snap.m_LocalClientID]; // first calculate where everyone should move for(int c = 0; c < MAX_CLIENTS; c++) { if(!World.m_apCharacters[c]) continue; mem_zero(&World.m_apCharacters[c]->m_Input, sizeof(World.m_apCharacters[c]->m_Input)); if(m_Snap.m_LocalClientID == c) { // apply player input int *pInput = Client()->GetInput(Tick); if(pInput) World.m_apCharacters[c]->m_Input = *((CNetObj_PlayerInput*)pInput); World.m_apCharacters[c]->Tick(true); } else World.m_apCharacters[c]->Tick(false); } // move all players and quantize their data for(int c = 0; c < MAX_CLIENTS; c++) { if(!World.m_apCharacters[c]) continue; World.m_apCharacters[c]->Move(); World.m_apCharacters[c]->Quantize(); } // check if we want to trigger effects if(Tick > m_LastNewPredictedTick) { m_LastNewPredictedTick = Tick; m_NewPredictedTick = true; if(m_Snap.m_LocalClientID != -1 && World.m_apCharacters[m_Snap.m_LocalClientID]) { vec2 Pos = World.m_apCharacters[m_Snap.m_LocalClientID]->m_Pos; int Events = World.m_apCharacters[m_Snap.m_LocalClientID]->m_TriggeredEvents; if(Events&COREEVENT_GROUND_JUMP) g_GameClient.m_pSounds->PlayAndRecord(CSounds::CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, Pos); /*if(events&COREEVENT_AIR_JUMP) { GameClient.effects->air_jump(pos); GameClient.sounds->play_and_record(SOUNDS::CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, pos); }*/ //if(events&COREEVENT_HOOK_LAUNCH) snd_play_random(CHN_WORLD, SOUND_HOOK_LOOP, 1.0f, pos); //if(events&COREEVENT_HOOK_ATTACH_PLAYER) snd_play_random(CHN_WORLD, SOUND_HOOK_ATTACH_PLAYER, 1.0f, pos); if(Events&COREEVENT_HOOK_ATTACH_GROUND) g_GameClient.m_pSounds->PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_ATTACH_GROUND, 1.0f, Pos); if(Events&COREEVENT_HOOK_HIT_NOHOOK) g_GameClient.m_pSounds->PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_NOATTACH, 1.0f, Pos); //if(events&COREEVENT_HOOK_RETRACT) snd_play_random(CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, pos); } } if(Tick == Client()->PredGameTick() && World.m_apCharacters[m_Snap.m_LocalClientID]) m_PredictedChar = *World.m_apCharacters[m_Snap.m_LocalClientID]; } if(g_Config.m_Debug && g_Config.m_ClPredict && m_PredictedTick == Client()->PredGameTick()) { CNetObj_CharacterCore Before = {0}, Now = {0}, BeforePrev = {0}, NowPrev = {0}; BeforeChar.Write(&Before); BeforePrevChar.Write(&BeforePrev); m_PredictedChar.Write(&Now); m_PredictedPrevChar.Write(&NowPrev); if(mem_comp(&Before, &Now, sizeof(CNetObj_CharacterCore)) != 0) { Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "prediction error"); for(unsigned i = 0; i < sizeof(CNetObj_CharacterCore)/sizeof(int); i++) if(((int *)&Before)[i] != ((int *)&Now)[i]) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), " %d %d %d (%d %d)", i, ((int *)&Before)[i], ((int *)&Now)[i], ((int *)&BeforePrev)[i], ((int *)&NowPrev)[i]); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf); } } } m_PredictedTick = Client()->PredGameTick();}
开发者ID:Milkax3,项目名称:TRP--TeeRolePlay-,代码行数:101,
示例30: CheckPureTuningvoid CGameContext::OnTick(){ // check tuning CheckPureTuning(); // copy tuning m_World.m_Core.m_Tuning = m_Tuning; m_World.Tick(); //if(world.paused) // make sure that the game object always updates m_pController->Tick(); for(int i = 0; i < MAX_CLIENTS; i++) { if(m_apPlayers[i]) m_apPlayers[i]->Tick(); } // update voting if(m_VoteCloseTime) { // abort the kick-vote on player-leave if(m_VoteCloseTime == -1) { SendChat(-1, CGameContext::CHAT_ALL, "Vote aborted"); EndVote(); } else { int Total = 0, Yes = 0, No = 0; if(m_VoteUpdate) { // count votes char aaBuf[MAX_CLIENTS][64] = {{0}}; for(int i = 0; i < MAX_CLIENTS; i++) if(m_apPlayers[i]) Server()->GetClientIP(i, aaBuf[i], 64); bool aVoteChecked[MAX_CLIENTS] = {0}; for(int i = 0; i < MAX_CLIENTS; i++) { if(!m_apPlayers[i] || m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS || aVoteChecked[i]) // don't count in votes by spectators continue; int ActVote = m_apPlayers[i]->m_Vote; int ActVotePos = m_apPlayers[i]->m_VotePos; // check for more players with the same ip (only use the vote of the one who voted first) for(int j = i+1; j < MAX_CLIENTS; ++j) { if(!m_apPlayers[j] || aVoteChecked[j] || str_comp(aaBuf[j], aaBuf[i])) continue; aVoteChecked[j] = true; if(m_apPlayers[j]->m_Vote && (!ActVote || ActVotePos > m_apPlayers[j]->m_VotePos)) { ActVote = m_apPlayers[j]->m_Vote; ActVotePos = m_apPlayers[j]->m_VotePos; } } Total++; if(ActVote > 0) Yes++; else if(ActVote < 0) No++; } if(Yes >= Total/2+1) m_VoteEnforce = VOTE_ENFORCE_YES; else if(No >= (Total+1)/2) m_VoteEnforce = VOTE_ENFORCE_NO; } if(m_VoteEnforce == VOTE_ENFORCE_YES) { Console()->ExecuteLine(m_aVoteCommand); EndVote(); SendChat(-1, CGameContext::CHAT_ALL, "Vote passed"); if(m_apPlayers[m_VoteCreator]) m_apPlayers[m_VoteCreator]->m_Last_VoteCall = 0; } else if(m_VoteEnforce == VOTE_ENFORCE_NO || time_get() > m_VoteCloseTime) { EndVote(); SendChat(-1, CGameContext::CHAT_ALL, "Vote failed"); } else if(m_VoteUpdate) { m_VoteUpdate = false; SendVoteStatus(-1, Total, Yes, No); } } } #ifdef CONF_DEBUG if(g_Config.m_DbgDummies) { for(int i = 0; i < g_Config.m_DbgDummies ; i++)//.........这里部分代码省略.........
开发者ID:CoolerMAN,项目名称:tdtw,代码行数:101,
注:本文中的Console函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ConsolePrint函数代码示例 C++ ConnectionNumber函数代码示例 |