本文整理汇总了C++中Console函数的典型用法代码示例。如果您正苦于以下问题:C++ Console函数的具体用法?C++ Console怎么用?C++ Console使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Console函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: str_format
void 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;
}
//.........这里部分代码省略.........
示例2: Console
void CMapLayers::OnConsoleInit()
{
Console()->Chain("cl_background_map", ConchainBackgroundMap, this);
}
示例3: mem_zero
void 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)
//.........这里部分代码省略.........
示例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;
}
}
}
}
示例5: ExtractArguments
int 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;
}
示例6: Storage
void 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;
}
示例7: while
void 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)
//.........这里部分代码省略.........
示例8: if
void 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;
}
}
}
示例9: url
void 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();
}
}
示例10: ShowHelp
static 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"
//.........这里部分代码省略.........
示例11: g
void 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 );
}
}
}
示例12: Console
void 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"); }
}
示例13: width
void 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();
//.........这里部分代码省略.........
示例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" ) );
//.........这里部分代码省略.........
示例15: Get
void 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);
}
}