您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Client函数代码示例

51自学网 2021-06-01 20:11:21
  C++
这篇教程C++ Client函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Client函数的典型用法代码示例。如果您正苦于以下问题:C++ Client函数的具体用法?C++ Client怎么用?C++ Client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Client函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Client

void CGameClient::OnGameOver(){	if(Client()->State() != IClient::STATE_DEMOPLAYBACK && g_Config.m_ClEditor == 0)		Client()->AutoScreenshot_Start();}
开发者ID:Learath2,项目名称:teeworlds,代码行数:5,


示例2: Client

boost::statechart::result MPLobby::react(const LobbyChat& msg) {    if (TRACE_EXECUTION) DebugLogger() << "(HumanClientFSM) MPLobby.LobbyChat";    Client().GetClientUI()->GetMultiPlayerLobbyWnd()->ChatMessage(msg.m_message.SendingPlayer(), msg.m_message.Text());    return discard_event();}
开发者ID:Ouaz,项目名称:freeorion,代码行数:5,


示例3: ResetPlayerStats

void CScoreboard::OnRender(){	// check if we need to reset the player stats	if(!m_SkipPlayerStatsReset && m_pClient->m_Snap.m_pGameData && m_pClient->m_Snap.m_pGameData->m_GameStartTick == Client()->GameTick())	{		m_SkipPlayerStatsReset = true;		for(int i = 0; i < MAX_CLIENTS; i++)			ResetPlayerStats(i);	}	else if(m_SkipPlayerStatsReset && m_pClient->m_Snap.m_pGameData && m_pClient->m_Snap.m_pGameData->m_GameStartTick != Client()->GameTick())		m_SkipPlayerStatsReset = false;	// postpone the active state till the render area gets updated during the rendering	if(m_Activate)	{		m_Active = true;		m_Activate = false;	}	// close the motd if we actively wanna look on the scoreboard	if(m_Active)		m_pClient->m_pMotd->Clear();	if(!Active())		return;	// don't render scoreboard if menu or motd is open	if(m_pClient->m_pMenus->IsActive() || m_pClient->m_pMotd->IsActive())		return;	CUIRect Screen = *UI()->Screen();	Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);	float Width = Screen.w;	float y = 85.f;	float w = 364.0f;	float FontSize = 86.0f;	const char* pCustomRedClanName = GetClanName(TEAM_RED);	const char* pCustomBlueClanName = GetClanName(TEAM_BLUE);	const char* pRedClanName = pCustomRedClanName ? pCustomRedClanName : Localize("Red team");	const char* pBlueClanName = pCustomBlueClanName ? pCustomBlueClanName : Localize("Blue team");	if(m_pClient->m_Snap.m_pGameData)	{		if(!(m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS))		{			float ScoreboardHeight = RenderScoreboard(Width/2-w/2, y, w, 0, 0, -1);			float SpectatorHeight = RenderSpectators(Width/2-w/2, y+3.0f+ScoreboardHeight, w);			RenderGoals(Width/2-w/2, y+3.0f+ScoreboardHeight, w);			// scoreboard size			m_TotalRect.x = Width/2-w/2;			m_TotalRect.y = y;			m_TotalRect.w = w;			m_TotalRect.h = ScoreboardHeight+SpectatorHeight+3.0f;		}		else if(m_pClient->m_Snap.m_pGameDataTeam)		{			float ScoreboardHeight = RenderScoreboard(Width/2-w-1.5f, y, w, TEAM_RED, pRedClanName, -1);			RenderScoreboard(Width/2+1.5f, y, w, TEAM_BLUE, pBlueClanName, 1);			float SpectatorHeight = RenderSpectators(Width/2-w-1.5f, y+3.0f+ScoreboardHeight, w*2.0f+3.0f);			RenderGoals(Width/2-w-1.5f, y+3.0f+ScoreboardHeight, w*2.0f+3.0f);			// scoreboard size			m_TotalRect.x = Width/2-w-1.5f;			m_TotalRect.y = y;			m_TotalRect.w = w*2.0f+3.0f;			m_TotalRect.h = ScoreboardHeight+SpectatorHeight+3.0f;		}	}	Width = 400*3.0f*Graphics()->ScreenAspect();	Graphics()->MapScreen(0, 0, Width, 400*3.0f);	if(m_pClient->m_Snap.m_pGameData && (m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS) && m_pClient->m_Snap.m_pGameDataTeam)	{		if(m_pClient->m_Snap.m_pGameData->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)		{			char aText[256];			if(m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreRed > m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreBlue)				str_format(aText, sizeof(aText), Localize("%s wins!"), pRedClanName);			else if(m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreBlue > m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreRed)				str_format(aText, sizeof(aText), Localize("%s wins!"), pBlueClanName);			else				str_copy(aText, Localize("Draw!"), sizeof(aText));			float tw = TextRender()->TextWidth(0, FontSize, aText, -1, -1.0f);			TextRender()->Text(0, Width/2-tw/2, 39, FontSize, aText, -1.0f);		}		else if(m_pClient->m_Snap.m_pGameData->m_GameStateFlags&GAMESTATEFLAG_ROUNDOVER)		{			char aText[256];			str_copy(aText, Localize("Round over!"), sizeof(aText));			float tw = TextRender()->TextWidth(0, FontSize, aText, -1, -1.0f);			TextRender()->Text(0, Width/2-tw/2, 39, FontSize, aText, -1.0f);			m_SkipPlayerStatsReset = true;//.........这里部分代码省略.........
开发者ID:BotoX,项目名称:teeworlds,代码行数:101,


示例4: DemolistPopulate

//.........这里部分代码省略.........		Left.VSplitLeft(20.0f, 0, &Left);		Left.VSplitLeft(130.0f, &Left, &Right);		UI()->DoLabelScaled(&Left, Localize("Crc:"), 14.0f, -1);		unsigned Crc = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[1]<<16) |					(m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[3]);		str_format(aBuf, sizeof(aBuf), "%08x", Crc);		UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1);		Labels.HSplitTop(5.0f, 0, &Labels);		Labels.HSplitTop(20.0f, &Left, &Labels);		Left.VSplitLeft(150.0f, &Left, &Right);		UI()->DoLabelScaled(&Left, Localize("Netversion:"), 14.0f, -1);		UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion, 14.0f, -1);	}	static int s_DemoListId = 0;	static float s_ScrollValue = 0;	UiDoListboxStart(&s_DemoListId, &ListBox, 17.0f, Localize("Demos"), aFooterLabel, m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue);	for(sorted_array<CDemoItem>::range r = m_lDemos.all(); !r.empty(); r.pop_front())	{		CListboxItem Item = UiDoListboxNextItem((void*)(&r.front()));		if(Item.m_Visible)		{			Item.m_Rect.VSplitLeft(Item.m_Rect.h, &FileIcon, &Item.m_Rect);			Item.m_Rect.VSplitLeft(5.0f, 0, &Item.m_Rect);			DoButton_Icon(IMAGE_FILEICONS, r.front().m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_DEMO1, &FileIcon);			UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight, -1);		}	}	bool Activated = false;	m_DemolistSelectedIndex = UiDoListboxEnd(&s_ScrollValue, &Activated);	DemolistOnUpdate(false);	static int s_RefreshButton = 0;	if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect))	{		DemolistPopulate();		DemolistOnUpdate(false);	}	static int s_PlayButton = 0;	if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir?Localize("Open"):Localize("Play"), 0, &PlayRect) || Activated)	{		if(m_DemolistSelectedIndex >= 0)		{			if(m_DemolistSelectedIsDir)	// folder			{				if(str_comp(m_lDemos[m_DemolistSelectedIndex].m_aFilename, "..") == 0)	// parent folder					fs_parent_dir(m_aCurrentDemoFolder);				else	// sub folder				{					char aTemp[256];					str_copy(aTemp, m_aCurrentDemoFolder, sizeof(aTemp));					str_format(m_aCurrentDemoFolder, sizeof(m_aCurrentDemoFolder), "%s/%s", aTemp, m_lDemos[m_DemolistSelectedIndex].m_aFilename);					m_DemolistStorageType = m_lDemos[m_DemolistSelectedIndex].m_StorageType;				}				DemolistPopulate();				DemolistOnUpdate(true);			}			else // file			{				char aBuf[512];				str_format(aBuf, sizeof(aBuf), "%s/%s", m_aCurrentDemoFolder, m_lDemos[m_DemolistSelectedIndex].m_aFilename);				const char *pError = Client()->DemoPlayer_Play(aBuf, m_lDemos[m_DemolistSelectedIndex].m_StorageType);				if(pError)					PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("Error loading demo"), Localize("Ok"));				else				{					UI()->SetActiveItem(0);					return;				}			}		}	}	if(!m_DemolistSelectedIsDir)	{		static int s_DeleteButton = 0;		if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed)		{			if(m_DemolistSelectedIndex >= 0)			{				UI()->SetActiveItem(0);				m_Popup = POPUP_DELETE_DEMO;				return;			}		}		static int s_RenameButton = 0;		if(DoButton_Menu(&s_RenameButton, Localize("Rename"), 0, &RenameRect))		{			if(m_DemolistSelectedIndex >= 0)			{				UI()->SetActiveItem(0);				m_Popup = POPUP_RENAME_DEMO;				str_copy(m_aCurrentDemoFile, m_lDemos[m_DemolistSelectedIndex].m_aFilename, sizeof(m_aCurrentDemoFile));				return;			}		}	}}
开发者ID:MJ89,项目名称:teeworlds,代码行数:101,


示例5: if

int CControls::SnapInput(int *pData){	static int64 LastSendTime = 0;	bool Send = false;	// update player state	if(m_pClient->m_pChat->IsActive())		m_InputData.m_PlayerFlags = PLAYERFLAG_CHATTING;	else if(m_pClient->m_pMenus->IsActive())		m_InputData.m_PlayerFlags = PLAYERFLAG_IN_MENU;	else		m_InputData.m_PlayerFlags = PLAYERFLAG_PLAYING;	if(m_pClient->m_pScoreboard->Active())		m_InputData.m_PlayerFlags |= PLAYERFLAG_SCOREBOARD;	if(m_LastData.m_PlayerFlags != m_InputData.m_PlayerFlags)		Send = true;	m_LastData.m_PlayerFlags = m_InputData.m_PlayerFlags;	// we freeze the input if chat or menu is activated	if(!(m_InputData.m_PlayerFlags&PLAYERFLAG_PLAYING))	{		OnReset();		mem_copy(pData, &m_InputData, sizeof(m_InputData));		// send once a second just to be sure		if(time_get() > LastSendTime + time_freq())			Send = true;	}	else	{		m_InputData.m_TargetX = (int)m_MousePos.x;		m_InputData.m_TargetY = (int)m_MousePos.y;		if(!m_InputData.m_TargetX && !m_InputData.m_TargetY)		{			m_InputData.m_TargetX = 1;			m_MousePos.x = 1;		}		// set direction		m_InputData.m_Direction = 0;		if(m_InputDirectionLeft && !m_InputDirectionRight)			m_InputData.m_Direction = -1;		if(!m_InputDirectionLeft && m_InputDirectionRight)			m_InputData.m_Direction = 1;		// stress testing		if(g_Config.m_DbgStress)		{			float t = Client()->LocalTime();			mem_zero(&m_InputData, sizeof(m_InputData));			m_InputData.m_Direction = ((int)t/2)&1;			m_InputData.m_Jump = ((int)t);			m_InputData.m_Fire = ((int)(t*10));			m_InputData.m_Hook = ((int)(t*2))&1;			m_InputData.m_WantedWeapon = ((int)t)%NUM_WEAPONS;			m_InputData.m_TargetX = (int)(sinf(t*3)*100.0f);			m_InputData.m_TargetY = (int)(cosf(t*3)*100.0f);		}		// check if we need to send input		if(m_InputData.m_Direction != m_LastData.m_Direction) Send = true;		else if(m_InputData.m_Jump != m_LastData.m_Jump) Send = true;		else if(m_InputData.m_Fire != m_LastData.m_Fire) Send = true;		else if(m_InputData.m_Hook != m_LastData.m_Hook) Send = true;		else if(m_InputData.m_WantedWeapon != m_LastData.m_WantedWeapon) Send = true;		else if(m_InputData.m_NextWeapon != m_LastData.m_NextWeapon) Send = true;		else if(m_InputData.m_PrevWeapon != m_LastData.m_PrevWeapon) Send = true;		// send at at least 10hz		if(time_get() > LastSendTime + time_freq()/25)			Send = true;	}	// copy and return size	m_LastData = m_InputData;	if(!Send)		return 0;	LastSendTime = time_get();	mem_copy(pData, &m_InputData, sizeof(m_InputData));	return sizeof(m_InputData);}
开发者ID:Fear-cool,项目名称:DDRace,代码行数:89,


示例6: Graphics

void CMenus::RenderStartMenu(CUIRect MainView){	// render logo	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_BANNER].m_Id);	Graphics()->QuadsBegin();	Graphics()->SetColor(1,1,1,1);	IGraphics::CQuadItem QuadItem(MainView.w/2-140, 60, 280, 70);	Graphics()->QuadsDrawTL(&QuadItem, 1);	Graphics()->QuadsEnd();	CUIRect TopMenu, BottomMenu;	MainView.VMargin(MainView.w/2-190.0f, &TopMenu);	TopMenu.HSplitTop(365.0f, &TopMenu, &BottomMenu);	//TopMenu.HSplitBottom(145.0f, &TopMenu, 0);	RenderTools()->DrawUIRect4(&TopMenu, vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 10.0f);	TopMenu.HSplitTop(145.0f, 0, &TopMenu);	CUIRect Button;	int NewPage = -1;	TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);	static CButtonContainer s_SettingsButton;	if(DoButton_Menu(&s_SettingsButton, Localize("Settings"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "settings" : 0, CUI::CORNER_ALL, 10.0f, 0.5f))		NewPage = PAGE_SETTINGS;		/*TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space	TopMenu.HSplitBottom(40.0f, &TopMenu, &Bottom);	static int s_LocalServerButton = 0;	if(g_Config.m_ClShowStartMenuImages)	{		if(DoButton_MenuImage(&s_LocalServerButton, Localize("Local server"), 0, &Button, "local_server", 10.0f, 0.5f))		{		}	}	else	{		if(DoButton_Menu(&s_LocalServerButton, Localize("Local server"), 0, &Button, CUI::CORNER_ALL, 10.0f, 0.5f))		{		}	}*/	TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space	TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);	static CButtonContainer s_DemoButton;	if(DoButton_Menu(&s_DemoButton, Localize("Demos"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "demos" : 0, CUI::CORNER_ALL, 10.0f, 0.5f))	{		NewPage = PAGE_DEMOS;		DemolistPopulate();		DemolistOnUpdate(false);	}	TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space	TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);	static CButtonContainer s_MapEditorButton;	if(DoButton_Menu(&s_MapEditorButton, Localize("Editor"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "editor" : 0, CUI::CORNER_ALL, 10.0f, 0.5f))	{		g_Config.m_ClEditor = 1;		Input()->MouseModeRelative();	}	TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space	TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);	static CButtonContainer s_PlayButton;	if(DoButton_Menu(&s_PlayButton, Localize("Play"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "play_game" : 0, CUI::CORNER_ALL, 10.0f, 0.5f) || m_EnterPressed)		NewPage = g_Config.m_UiBrowserPage;		BottomMenu.HSplitTop(90.0f, 0, &BottomMenu);	RenderTools()->DrawUIRect4(&BottomMenu, vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), CUI::CORNER_T, 10.0f);	BottomMenu.HSplitTop(40.0f, &Button, &TopMenu);	static CButtonContainer s_QuitButton;	if(DoButton_Menu(&s_QuitButton, Localize("Quit"), 0, &Button, 0, CUI::CORNER_ALL, 10.0f, 0.5f) || m_EscapePressed)		m_Popup = POPUP_QUIT;	// render version	CUIRect Version;	MainView.HSplitBottom(50.0f, 0, &Version);	Version.VMargin(50.0f, &Version);	char aBuf[64];	if(str_comp(Client()->LatestVersion(), "0") != 0)	{		str_format(aBuf, sizeof(aBuf), Localize("Teeworlds %s is out! Download it at www.teeworlds.com!"), Client()->LatestVersion());		TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);		UI()->DoLabelScaled(&Version, aBuf, 14.0f, CUI::ALIGN_CENTER);		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);	}	UI()->DoLabelScaled(&Version, GAME_VERSION, 14.0f, CUI::ALIGN_RIGHT);	if(NewPage != -1)		SetMenuPage(NewPage);}
开发者ID:Fisico,项目名称:teeworlds,代码行数:92,


示例7: Storage

void CGameClient::OnInit(){	// set the language	g_Localization.Load(g_Config.m_ClLanguagefile, Storage(), Console());		// init all components	for(int i = 0; i < m_All.m_Num; i++)		m_All.m_paComponents[i]->OnInit();		// setup item sizes	for(int i = 0; i < NUM_NETOBJTYPES; i++)		Client()->SnapSetStaticsize(i, m_NetObjHandler.GetObjSize(i));		int64 Start = time_get();		// load default font		static CFont *pDefaultFont = 0;	char aFilename[512];	IOHANDLE File = Storage()->OpenFile("fonts/DejaVuSans.ttf", IOFLAG_READ, IStorage::TYPE_ALL, aFilename, sizeof(aFilename));	if(File)	{		io_close(File);		pDefaultFont = TextRender()->LoadFont(aFilename);		TextRender()->SetDefaultFont(pDefaultFont);	}	if(!pDefaultFont)		Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", "failed to load font. filename='fonts/DejaVuSans.ttf'");	g_Config.m_ClThreadsoundloading = 0;	// setup load amount	gs_LoadTotal = g_pData->m_NumImages;	gs_LoadCurrent = 0;	if(!g_Config.m_ClThreadsoundloading)		gs_LoadTotal += g_pData->m_NumSounds;		// load textures	for(int i = 0; i < g_pData->m_NumImages; i++)	{		g_GameClient.m_pMenus->RenderLoading(gs_LoadCurrent/(float)gs_LoadTotal);		g_pData->m_aImages[i].m_Id = Graphics()->LoadTexture(g_pData->m_aImages[i].m_pFilename, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);		gs_LoadCurrent++;	}	// load skins	::gs_Skins.Init();		// TODO: Refactor: fix threaded loading of sounds again	// load sounds	{		bool DoRender = true;		for(int s = 0; s < g_pData->m_NumSounds; s++)		{			if(DoRender)				g_GameClient.m_pMenus->RenderLoading(gs_LoadCurrent/(float)gs_LoadTotal);			for(int i = 0; i < g_pData->m_aSounds[s].m_NumSounds; i++)			{				int Id = Sound()->LoadWV(g_pData->m_aSounds[s].m_aSounds[i].m_pFilename);				g_pData->m_aSounds[s].m_aSounds[i].m_Id = Id;			}			if(DoRender)				gs_LoadCurrent++;		}	}			/*if(config.cl_threadsoundloading)		thread_create(load_sounds_thread, 0);	else		load_sounds_thread((void*)1);*/	for(int i = 0; i < m_All.m_Num; i++)		m_All.m_paComponents[i]->OnReset();		int64 End = time_get();	char aBuf[256];	str_format(aBuf, sizeof(aBuf), "initialisation finished after %.2fms", ((End-Start)*1000)/(float)time_freq());	Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "gameclient", aBuf);		m_ServerMode = SERVERMODE_PURE;}
开发者ID:Landil,项目名称:teeworlds,代码行数:81,


示例8: msg_unpack_int

void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker){		// special messages	if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE)	{		/*		int num = msg_unpack_int();				for(int k = 0; k < num; k++)		{			NETOBJ_PROJECTILE proj;			for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)				((int *)&proj)[i] = msg_unpack_int();							if(msg_unpack_error())				return;							if(extraproj_num != MAX_EXTRA_PROJECTILES)			{				extraproj_projectiles[extraproj_num] = proj;				extraproj_num++;			}		}				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_Cid].m_Emoticon = pMsg->m_Emoticon;		m_aClients[pMsg->m_Cid].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(pMsg->m_Soundid);		else			g_GameClient.m_pSounds->Play(CSounds::CHN_GLOBAL, pMsg->m_Soundid, 1.0f, vec2(0,0));	}		}
开发者ID:Landil,项目名称:teeworlds,代码行数:86,


示例9: Spectate

void CSpectator::OnRender(){	if(!m_Active)	{		if(m_WasActive)		{			if(m_SelectedSpectatorID != NO_SELECTION)				Spectate(m_SelectedSpectatorID);			m_WasActive = false;		}		return;	}	if(!m_pClient->m_Snap.m_SpecInfo.m_Active && Client()->State() != IClient::STATE_DEMOPLAYBACK)	{		m_Active = false;		m_WasActive = false;		return;	}	m_WasActive = true;	m_SelectedSpectatorID = NO_SELECTION;	// draw background	float Width = 400*3.0f*Graphics()->ScreenAspect();	float Height = 400*3.0f;	float ObjWidth = 300.0f;	float FontSize = 20.0f;	float BigFontSize = 20.0f;	float StartY = -190.0f;	float LineHeight = 60.0f;	float TeeSizeMod = 1.0f;	float RoundRadius = 30.0f;	bool Selected = false;	int TotalPlayers = 0;	int PerLine = 8;	float BoxMove = -10.0f;	for(int i = 0; i < MAX_CLIENTS; ++i)	{		if(!m_pClient->m_Snap.m_paInfoByDDTeam[i] || m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_Team == TEAM_SPECTATORS)			continue;		++TotalPlayers;	}	if (TotalPlayers > 32)	{		FontSize = 18.0f;		LineHeight = 30.0f;		TeeSizeMod = 0.7f;		PerLine = 16;		RoundRadius = 10.0f;		BoxMove = 3.0f;	}	if (TotalPlayers > 16)	{		ObjWidth = 600.0f;	}	Graphics()->MapScreen(0, 0, Width, Height);	Graphics()->BlendNormal();	Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();	Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f);	RenderTools()->DrawRoundRect(Width/2.0f-ObjWidth, Height/2.0f-300.0f, ObjWidth*2, 600.0f, 20.0f);	Graphics()->QuadsEnd();	// clamp mouse position to selector area	m_SelectorMouse.x = clamp(m_SelectorMouse.x, -(ObjWidth - 20.0f), ObjWidth - 20.0f);	m_SelectorMouse.y = clamp(m_SelectorMouse.y, -280.0f, 280.0f);	// draw selections	if((Client()->State() == IClient::STATE_DEMOPLAYBACK && m_pClient->m_DemoSpecID == SPEC_FREEVIEW) ||		 m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW)	{		Graphics()->TextureSet(-1);		Graphics()->QuadsBegin();		Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);		RenderTools()->DrawRoundRect(Width/2.0f-(ObjWidth - 20.0f), Height/2.0f-280.0f, 270.0f, 60.0f, 20.0f);		Graphics()->QuadsEnd();	}	if(Client()->State() == IClient::STATE_DEMOPLAYBACK && m_pClient->m_DemoSpecID == SPEC_FOLLOW)	{		Graphics()->TextureSet(-1);		Graphics()->QuadsBegin();		Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);		RenderTools()->DrawRoundRect(Width/2.0f-(ObjWidth - 310.0f), Height/2.0f-280.0f, 270.0f, 60.0f, 20.0f);		Graphics()->QuadsEnd();	}	if(m_SelectorMouse.x >= -(ObjWidth-20.0f) && m_SelectorMouse.x <= -(ObjWidth-290+10.0f) &&		m_SelectorMouse.y >= -280.0f && m_SelectorMouse.y <= -220.0f)	{		m_SelectedSpectatorID = SPEC_FREEVIEW;		Selected = true;	}	TextRender()->TextColor(1.0f, 1.0f, 1.0f, Selected?1.0f:0.5f);//.........这里部分代码省略.........
开发者ID:ddnet,项目名称:ddnet,代码行数:101,


示例10: Client

void CGameClient::SendKill(int ClientId){	CNetMsg_Cl_Kill Msg;	Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);	}
开发者ID:Landil,项目名称:teeworlds,代码行数:5,


示例11: TEST_F

TEST_F(DiscoveringResourcesTestFixtures, findResourceAfterInit){    Client c2 = Client();    EXPECT_FALSE(c2.hasResourceDiscovered(ls->getResourceURI()));}
开发者ID:yoyko,项目名称:TentaclIoT,代码行数:4,


示例12: if

//.........这里部分代码省略.........	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BAR].m_Id);	Graphics()->QuadsBegin();	Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.9f);	Graphics()->QuadsSetSubset(0,0.1f,Screen.w*0.015f,1-0.1f);	QuadItem = IGraphics::CQuadItem(0,ConsoleHeight-10.0f,Screen.w,10.0f);	Graphics()->QuadsDrawTL(&QuadItem, 1);	Graphics()->QuadsEnd();	ConsoleHeight -= 22.0f;	CInstance *pConsole = CurrentConsole();	{		float FontSize = 10.0f;		float RowHeight = FontSize*1.25f;		float x = 3;		float y = ConsoleHeight - RowHeight - 5.0f;		CRenderInfo Info;		Info.m_pSelf = this;		Info.m_WantedCompletion = pConsole->m_CompletionChosen;		Info.m_EnumCount = 0;		Info.m_Offset = pConsole->m_CompletionRenderOffset;		Info.m_Width = Screen.w;		Info.m_pCurrentCmd = pConsole->m_aCompletionBuffer;		TextRender()->SetCursor(&Info.m_Cursor, x+Info.m_Offset, y+RowHeight+2.0f, FontSize, TEXTFLAG_RENDER);		// render prompt		CTextCursor Cursor;		TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER);		const char *pPrompt = "> ";		if(m_ConsoleType == CONSOLETYPE_REMOTE)		{			if(Client()->State() == IClient::STATE_ONLINE)			{				if(Client()->RconAuthed())					pPrompt = "rcon> ";				else					pPrompt = "ENTER PASSWORD> ";			}			else				pPrompt = "NOT CONNECTED> ";		}		TextRender()->TextEx(&Cursor, pPrompt, -1);		x = Cursor.m_X;		// render console input (wrap line)		int Lines = TextRender()->TextLineCount(0, FontSize, pConsole->m_Input.GetString(), Screen.w - 10.0f - x);		y -= (Lines - 1) * FontSize;		TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER);		Cursor.m_LineWidth = Screen.w - 10.0f - x;		//hide rcon password		char aInputString[256];		str_copy(aInputString, pConsole->m_Input.GetString(), sizeof(aInputString));		if(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed())		{			for(int i = 0; i < pConsole->m_Input.GetLength(); ++i)				aInputString[i] = '*';		}		TextRender()->TextEx(&Cursor, aInputString, pConsole->m_Input.GetCursorOffset());		static float MarkerOffset = TextRender()->TextWidth(0, FontSize, "|", -1)/3;		CTextCursor Marker = Cursor;		Marker.m_X -= MarkerOffset;
开发者ID:Glycerius,项目名称:teeworlds,代码行数:67,


示例13: mem_zero

void CGameClient::OnNewSnapshot(){	// clear out the invalid pointers	mem_zero(&m_Snap, sizeof(m_Snap));	// secure snapshot	{		int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT);		for(int Index = 0; Index < Num; Index++)		{			IClient::CSnapItem Item;			const 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 = random_int()%(sizeof(aMessage)-1);			for(int i = 0; i < MsgLen; i++)				aMessage[i] = 'a'+(random_int()%('z'-'a'));			aMessage[MsgLen] = 0;			CNetMsg_Cl_Say Msg;			Msg.m_Mode = random_int()&1;			Msg.m_Target = -1;			Msg.m_pMessage = aMessage;			Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);		}	}	CTuningParams StandardTuning;	if(Client()->State() == IClient::STATE_DEMOPLAYBACK)	{		m_Tuning = StandardTuning;		mem_zero(&m_GameInfo, sizeof(m_GameInfo));	}	// go trough all the items in the snapshot and gather the info we want	{		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);			// demo items			if(Client()->State() == IClient::STATE_DEMOPLAYBACK)			{				if(Item.m_Type == NETOBJTYPE_DE_CLIENTINFO)				{					const CNetObj_De_ClientInfo *pInfo = (const CNetObj_De_ClientInfo *)pData;					int ClientID = Item.m_ID;					CClientData *pClient = &m_aClients[ClientID];					if(pInfo->m_Local)						m_LocalClientID = ClientID;					pClient->m_Active = true;					pClient->m_Team  = pInfo->m_Team;					IntsToStr(pInfo->m_aName, 4, pClient->m_aName);					IntsToStr(pInfo->m_aClan, 3, pClient->m_aClan);					pClient->m_Country = pInfo->m_Country;					for(int p = 0; p < NUM_SKINPARTS; p++)					{						IntsToStr(pInfo->m_aaSkinPartNames[p], 6, pClient->m_aaSkinPartNames[p]);						pClient->m_aUseCustomColors[p] = pInfo->m_aUseCustomColors[p];						pClient->m_aSkinPartColors[p] = pInfo->m_aSkinPartColors[p];					}					m_GameInfo.m_NumPlayers++;					// calculate team-balance					if(pClient->m_Team != TEAM_SPECTATORS)						m_GameInfo.m_aTeamSize[pClient->m_Team]++;				}				else if(Item.m_Type == NETOBJTYPE_DE_GAMEINFO)				{					const CNetObj_De_GameInfo *pInfo = (const CNetObj_De_GameInfo *)pData;					m_GameInfo.m_GameFlags = pInfo->m_GameFlags;					m_GameInfo.m_ScoreLimit = pInfo->m_ScoreLimit;					m_GameInfo.m_TimeLimit = pInfo->m_TimeLimit;					m_GameInfo.m_MatchNum = pInfo->m_MatchNum;					m_GameInfo.m_MatchCurrent = pInfo->m_MatchCurrent;				}				else if(Item.m_Type == NETOBJTYPE_DE_TUNEPARAMS)//.........这里部分代码省略.........
开发者ID:Learath2,项目名称:teeworlds,代码行数:101,


示例14: Graphics

void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter){	if(!pCharacter)		return;	float x = 5;	float y = 5;	int i;	IGraphics::CQuadItem Array[10];	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);	Graphics()->WrapClamp();	Graphics()->QuadsBegin();	Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);	// render ammo	if(pCharacter->m_Weapon == WEAPON_NINJA)	{		const int Max = g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000;		float NinjaProgress = clamp(pCharacter->m_AmmoCount-Client()->GameTick(), 0, Max) / (float)Max;		RenderNinjaBar(x, y+24.f, NinjaProgress);	}	else	{		RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[pCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteProj);		if(pCharacter->m_Weapon == WEAPON_GRENADE)		{			for(i = 0; i < min(pCharacter->m_AmmoCount, 10); i++)				Array[i] = IGraphics::CQuadItem(x+1+i*12, y+24, 10, 10);		}		else		{			for(i = 0; i < min(pCharacter->m_AmmoCount, 10); i++)				Array[i] = IGraphics::CQuadItem(x+i*12, y+24, 12, 12);		}		Graphics()->QuadsDrawTL(Array, i);	}	int h = 0;	// render health	RenderTools()->SelectSprite(SPRITE_HEALTH_FULL);	for(; h < min(pCharacter->m_Health, 10); h++)		Array[h] = IGraphics::CQuadItem(x+h*12,y,12,12);	Graphics()->QuadsDrawTL(Array, h);	i = 0;	RenderTools()->SelectSprite(SPRITE_HEALTH_EMPTY);	for(; h < 10; h++)		Array[i++] = IGraphics::CQuadItem(x+h*12,y,12,12);	Graphics()->QuadsDrawTL(Array, i);	// render armor meter	h = 0;	RenderTools()->SelectSprite(SPRITE_ARMOR_FULL);	for(; h < min(pCharacter->m_Armor, 10); h++)		Array[h] = IGraphics::CQuadItem(x+h*12,y+12,12,12);	Graphics()->QuadsDrawTL(Array, h);	i = 0;	RenderTools()->SelectSprite(SPRITE_ARMOR_EMPTY);	for(; h < 10; h++)		Array[i++] = IGraphics::CQuadItem(x+h*12,y+12,12,12);	Graphics()->QuadsDrawTL(Array, i);	Graphics()->QuadsEnd();	Graphics()->WrapNormal();}
开发者ID:BotoX,项目名称:teeworlds,代码行数:68,


示例15: Localize

void CHud::RenderPauseTimer(){	if((m_pClient->m_Snap.m_pGameData->m_GameStateFlags&(GAMESTATEFLAG_STARTCOUNTDOWN|GAMESTATEFLAG_PAUSED)) == GAMESTATEFLAG_PAUSED)	{		char aBuf[256];		const char *pText = Localize("Game paused");		float FontSize = 20.0f;		float w = TextRender()->TextWidth(0, FontSize, pText, -1, -1.0f);		TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 50, FontSize, pText, -1.0f);		FontSize = 16.0f;		if(m_pClient->m_Snap.m_pGameData->m_GameStateEndTick == 0)		{			if(m_pClient->m_Snap.m_NotReadyCount == 1)				str_format(aBuf, sizeof(aBuf), Localize("%d player not ready"), m_pClient->m_Snap.m_NotReadyCount);			else if(m_pClient->m_Snap.m_NotReadyCount > 1)				str_format(aBuf, sizeof(aBuf), Localize("%d players not ready"), m_pClient->m_Snap.m_NotReadyCount);			else				return;			RenderReadyUpNotification();		}		else		{			float Seconds = static_cast<float>(m_pClient->m_Snap.m_pGameData->m_GameStateEndTick-Client()->GameTick())/SERVER_TICK_SPEED;			if(Seconds < 5)				str_format(aBuf, sizeof(aBuf), "%.1f", Seconds);			else				str_format(aBuf, sizeof(aBuf), "%d", round_to_int(Seconds));		}		w = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);		TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 75, FontSize, aBuf, -1.0f);	}}
开发者ID:BotoX,项目名称:teeworlds,代码行数:33,


示例16: Client

void GWindow::Pour(){	GRegion Client(GetClient());	GRegion Update;	bool HasTools = false;	GViewI *v;	{		GRegion Tools;		for (v = Children.First(); v; v = Children.Next())		{			GView *k = dynamic_cast<GView*>(v);			if (k && k->_IsToolBar)			{				GRect OldPos = v->GetPos();				Update.Union(&OldPos);				if (HasTools)				{					// 2nd and later toolbars					if (v->Pour(Tools))					{						if (!v->Visible())						{							v->Visible(true);						}						if (OldPos != v->GetPos())						{							// position has changed update...							v->Invalidate();						}						Tools.Subtract(&v->GetPos());						Update.Subtract(&v->GetPos());					}				}				else				{					// First toolbar					if (v->Pour(Client))					{						HasTools = true;						if (!v->Visible())						{							v->Visible(true);						}						if (OldPos != v->GetPos())						{							v->Invalidate();						}						GRect Bar(v->GetPos());						Bar.x2 = GetClient().x2;						Tools = Bar;						Tools.Subtract(&v->GetPos());						Client.Subtract(&Bar);						Update.Subtract(&Bar);					}				}			}		}	}	for (v = Children.First(); v; v = Children.Next())	{		GView *k = dynamic_cast<GView*>(v);		if (!(k && k->_IsToolBar))		{			GRect OldPos = v->GetPos();			Update.Union(&OldPos);			if (v->Pour(Client))			{				if (!v->Visible())				{					v->Visible(true);				}				if (OldPos != v->GetPos())				{					// position has changed update...					v->Invalidate();				}				Client.Subtract(&v->GetPos());				Update.Subtract(&v->GetPos());			}			else			{				// make the view not visible				// v->Visible(FALSE);			}		}	}	for (int i=0; i<Update.Length(); i++)//.........这里部分代码省略.........
开发者ID:FEI17N,项目名称:Lgi,代码行数:101,


示例17: 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_LocalCid = -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 Cid = Item.m_Id;				IntsToStr(&pInfo->m_Name0, 6, m_aClients[Cid].m_aName);				IntsToStr(&pInfo->m_Skin0, 6, m_aClients[Cid].m_aSkinName);								m_aClients[Cid].m_UseCustomColor = pInfo->m_UseCustomColor;				m_aClients[Cid].m_ColorBody = pInfo->m_ColorBody;				m_aClients[Cid].m_ColorFeet = pInfo->m_ColorFeet;								// prepare the info				if(m_aClients[Cid].m_aSkinName[0] == 'x' || m_aClients[Cid].m_aSkinName[1] == '_')					str_copy(m_aClients[Cid].m_aSkinName, "default", 64);									m_aClients[Cid].m_SkinInfo.m_ColorBody = m_pSkins->GetColorV4(m_aClients[Cid].m_ColorBody);				m_aClients[Cid].m_SkinInfo.m_ColorFeet = m_pSkins->GetColorV4(m_aClients[Cid].m_ColorFeet);				m_aClients[Cid].m_SkinInfo.m_Size = 64;								// find new skin				m_aClients[Cid].m_SkinId = g_GameClient.m_pSkins->Find(m_aClients[Cid].m_aSkinName);				if(m_aClients[Cid].m_SkinId < 0)				{					m_aClients[Cid].m_SkinId = g_GameClient.m_pSkins->Find("default");					if(m_aClients[Cid].m_SkinId < 0)						m_aClients[Cid].m_SkinId = 0;				}								if(m_aClients[Cid].m_UseCustomColor)					m_aClients[Cid].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(m_aClients[Cid].m_SkinId)->m_ColorTexture;				else				{					m_aClients[Cid].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(m_aClients[Cid].m_SkinId)->m_OrgTexture;					m_aClients[Cid].m_SkinInfo.m_ColorBody = vec4(1,1,1,1);					m_aClients[Cid].m_SkinInfo.m_ColorFeet = vec4(1,1,1,1);				}				m_aClients[Cid].UpdateRenderInfo();				g_GameClient.m_Snap.m_NumPlayers++;							}			else if(Item.m_Type == NETOBJTYPE_PLAYERINFO)			{//.........这里部分代码省略.........
开发者ID:Landil,项目名称:teeworlds,代码行数:101,


示例18: main

int main( int argc, char ** argv ){    NETRESOURCE nr = {0};    DWORD dwRetVal = 0;    int c = 0;    char host[32] = {0};    LOGINFO LogInfo = {0};    while ( ( c = getopt( argc, argv, "h:u:p:e:") ) != -1 )    {        switch ( c )        {        // 目标ip        case 'h':            strncpy( host, optarg, 32 );        	break;        // 用户名        case 'u':            strncpy( LogInfo.szUserName, optarg, NAME_LEN );        	break;        // 密码        case 'p':            strncpy( LogInfo.szPassword, optarg, PASSWD_LEN );        	break;        // cmd        case 'e':            strncpy( LogInfo.szExcuteCmd, optarg, CMD_LEN );        	break;        default:            break;        }    }    char szRemoteName[MAX_PATH] = {0};    if ( host[0] )        sprintf( szRemoteName, "////%s//%s", host, ADMIN );    else        usage();    if ( !LogInfo.szUserName[0] || !LogInfo.szPassword[0] )        usage();    nr.dwType = RESOURCETYPE_ANY;    nr.lpLocalName = NULL;    nr.lpRemoteName = szRemoteName;    nr.lpProvider =  NULL;    dwRetVal = WNetAddConnection3( NULL, &nr, LogInfo.szPassword, LogInfo.szUserName, 0 );    if ( dwRetVal != NO_ERROR )    {        int a = GetLastError();        return -1;    }    InstallRemoteService( host );    Client( host, &LogInfo );    WNetCancelConnection( nr.lpRemoteName, TRUE );    return 0;}
开发者ID:Yt1g3r,项目名称:smbexec,代码行数:72,


示例19: Collision

void CGameClient::OnPredict(){	// store the previous values so we can detect prediction errors	CCharacterCore BeforePrevChar = m_PredictedPrevChar;	CCharacterCore BeforeChar = m_PredictedChar;	// we can't predict without our own id or own character	if(m_Snap.m_LocalCid == -1 || !m_Snap.m_aCharacters[m_Snap.m_LocalCid].m_Active)		return;		// don't predict anything if we are paused	if(m_Snap.m_pGameobj && m_Snap.m_pGameobj->m_Paused)	{		if(m_Snap.m_pLocalCharacter)			m_PredictedChar.Read(m_Snap.m_pLocalCharacter);		if(m_Snap.m_pLocalPrevCharacter)			m_PredictedPrevChar.Read(m_Snap.m_pLocalPrevCharacter);		return;	}	// repredict character	CWorldCore World;	World.m_Tuning = m_Tuning;	// search for players	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_LocalCid])			m_PredictedPrevChar = *World.m_apCharacters[m_Snap.m_LocalCid];				// 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_LocalCid == 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_LocalCid != -1 && World.m_apCharacters[m_Snap.m_LocalCid])			{				vec2 Pos = World.m_apCharacters[m_Snap.m_LocalCid]->m_Pos;				int Events = World.m_apCharacters[m_Snap.m_LocalCid]->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_LocalCid])			m_PredictedChar = *World.m_apCharacters[m_Snap.m_LocalCid];//.........这里部分代码省略.........
开发者ID:Landil,项目名称:teeworlds,代码行数:101,


示例20: DemoPlayer

void CMenus::RenderDemoPlayer(CUIRect MainView){	const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();	const float SeekBarHeight = 15.0f;	const float ButtonbarHeight = 20.0f;	const float NameBarHeight = 20.0f;	const float Margins = 5.0f;	float TotalHeight;	if(m_MenuActive)		TotalHeight = SeekBarHeight+ButtonbarHeight+NameBarHeight+Margins*3;	else		TotalHeight = SeekBarHeight+Margins*2;	MainView.HSplitBottom(TotalHeight, 0, &MainView);	MainView.VSplitLeft(50.0f, 0, &MainView);	MainView.VSplitRight(450.0f, &MainView, 0);	RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_T, 10.0f);	MainView.Margin(5.0f, &MainView);	CUIRect SeekBar, ButtonBar, NameBar;	int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick;	int TotalTicks = pInfo->m_LastTick - pInfo->m_FirstTick;	if(m_MenuActive)	{		MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar);		ButtonBar.HSplitTop(Margins, 0, &ButtonBar);		ButtonBar.HSplitBottom(NameBarHeight, &ButtonBar, &NameBar);		NameBar.HSplitTop(4.0f, 0, &NameBar);	}	else		SeekBar = MainView;	// do seekbar	{		static int s_SeekBarID = 0;		void *id = &s_SeekBarID;		char aBuffer[128];		RenderTools()->DrawUIRect(&SeekBar, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 5.0f);		float Amount = CurrentTick/(float)TotalTicks;		CUIRect FilledBar = SeekBar;		FilledBar.w = 10.0f + (FilledBar.w-10.0f)*Amount;		RenderTools()->DrawUIRect(&FilledBar, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 5.0f);		str_format(aBuffer, sizeof(aBuffer), "%d:%02d / %d:%02d",			CurrentTick/SERVER_TICK_SPEED/60, (CurrentTick/SERVER_TICK_SPEED)%60,			TotalTicks/SERVER_TICK_SPEED/60, (TotalTicks/SERVER_TICK_SPEED)%60);		UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h*0.70f, 0);		// do the logic		int Inside = UI()->MouseInside(&SeekBar);		if(UI()->ActiveItem() == id)		{			if(!UI()->MouseButton(0))				UI()->SetActiveItem(0);			else			{				static float PrevAmount = 0.0f;				float Amount = (UI()->MouseX()-SeekBar.x)/(float)SeekBar.w;				if(Amount > 0.0f && Amount < 1.0f && absolute(PrevAmount-Amount) >= 0.01f)				{					PrevAmount = Amount;					m_pClient->OnReset();					m_pClient->m_SuppressEvents = true;					DemoPlayer()->SetPos(Amount);					m_pClient->m_SuppressEvents = false;				}			}		}		else if(UI()->HotItem() == id)		{			if(UI()->MouseButton(0))				UI()->SetActiveItem(id);		}		if(Inside)			UI()->SetHotItem(id);	}	if(CurrentTick == TotalTicks)	{		m_pClient->OnReset();		DemoPlayer()->Pause();		DemoPlayer()->SetPos(0);	}	bool IncreaseDemoSpeed = false, DecreaseDemoSpeed = false;	if(m_MenuActive)	{//.........这里部分代码省略.........
开发者ID:MJ89,项目名称:teeworlds,代码行数:101,


示例21: Emote

void CEmoticon::OnRender(){	if(!m_Active)	{		if(m_WasActive && m_SelectedEmote != -1)			Emote(m_SelectedEmote);		if(m_WasActive && m_SelectedEyeEmote != -1)			EyeEmote(m_SelectedEyeEmote);		m_WasActive = false;		return;	}	if(m_pClient->m_Snap.m_SpecInfo.m_Active)	{		m_Active = false;		m_WasActive = false;		return;	}	m_WasActive = true;	if (length(m_SelectorMouse) > 170.0f)		m_SelectorMouse = normalize(m_SelectorMouse) * 170.0f;	float SelectedAngle = GetAngle(m_SelectorMouse) + 2*pi/24;	if (SelectedAngle < 0)		SelectedAngle += 2*pi;	m_SelectedEmote = -1;	m_SelectedEyeEmote = -1;	if (length(m_SelectorMouse) > 110.0f)		m_SelectedEmote = (int)(SelectedAngle / (2*pi) * NUM_EMOTICONS);	else if(length(m_SelectorMouse) > 40.0f)		m_SelectedEyeEmote = (int)(SelectedAngle / (2*pi) * NUM_EMOTES);	CUIRect Screen = *UI()->Screen();	Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);	Graphics()->BlendNormal();	Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();	Graphics()->SetColor(0,0,0,0.3f);	DrawCircle(Screen.w/2, Screen.h/2, 190.0f, 64);	Graphics()->QuadsEnd();	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_EMOTICONS].m_Id);	Graphics()->QuadsBegin();	for (int i = 0; i < NUM_EMOTICONS; i++)	{		float Angle = 2*pi*i/NUM_EMOTICONS;		if (Angle > pi)			Angle -= 2*pi;		bool Selected = m_SelectedEmote == i;		float Size = Selected ? 80.0f : 50.0f;		float NudgeX = 150.0f * cosf(Angle);		float NudgeY = 150.0f * sinf(Angle);		RenderTools()->SelectSprite(SPRITE_OOP + i);		IGraphics::CQuadItem QuadItem(Screen.w/2 + NudgeX, Screen.h/2 + NudgeY, Size, Size);		Graphics()->QuadsDraw(&QuadItem, 1);	}	Graphics()->QuadsEnd();	CServerInfo pServerInfo;	Client()->GetServerInfo(&pServerInfo);	if((IsDDRace(&pServerInfo) || IsDDNet(&pServerInfo) || IsPlus(&pServerInfo)) && g_Config.m_ClEyeWheel)	{		Graphics()->TextureSet(-1);		Graphics()->QuadsBegin();		Graphics()->SetColor(1.0,1.0,1.0,0.3f);		DrawCircle(Screen.w/2, Screen.h/2, 100.0f, 64);		Graphics()->QuadsEnd();		CTeeRenderInfo *pTeeInfo = &m_pClient->m_aClients[m_pClient->m_LocalIDs[g_Config.m_ClDummy]].m_RenderInfo;		Graphics()->TextureSet(pTeeInfo->m_Texture);		for (int i = 0; i < NUM_EMOTES; i++)		{			float Angle = 2*pi*i/NUM_EMOTES;			if (Angle > pi)				Angle -= 2*pi;			bool Selected = m_SelectedEyeEmote == i;			float NudgeX = 70.0f * cosf(Angle);			float NudgeY = 70.0f * sinf(Angle);			pTeeInfo->m_Size = Selected ? 64.0f : 48.0f;			RenderTools()->RenderTee(CAnimState::GetIdle(), pTeeInfo, i, vec2(-1,0), vec2(Screen.w/2 + NudgeX, Screen.h/2 + NudgeY));			pTeeInfo->m_Size = 64.0f;		}//.........这里部分代码省略.........
开发者ID:BannZay,项目名称:ddnet,代码行数:101,


示例22: str_format

void CHud::RenderScoreHud(){	// render small score hud	if(!(m_pClient->m_Snap.m_pGameData->m_GameStateFlags&(GAMESTATEFLAG_ROUNDOVER|GAMESTATEFLAG_GAMEOVER)))	{		int GameFlags = m_pClient->m_GameInfo.m_GameFlags;		float Whole = 300*Graphics()->ScreenAspect();		float StartY = 229.0f;		if(GameFlags&GAMEFLAG_TEAMS && m_pClient->m_Snap.m_pGameDataTeam)		{			char aScoreTeam[2][32];			str_format(aScoreTeam[TEAM_RED], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreRed);			str_format(aScoreTeam[TEAM_BLUE], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreBlue);			float aScoreTeamWidth[2] = { TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_RED], -1, -1.0f), TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_BLUE], -1, -1.0f) };			float ScoreWidthMax = max(max(aScoreTeamWidth[TEAM_RED], aScoreTeamWidth[TEAM_BLUE]), TextRender()->TextWidth(0, 14.0f, "100", -1, -1.0f));			float Split = 3.0f;			float ImageSize = GameFlags&GAMEFLAG_FLAGS ? 16.0f : Split;			for(int t = 0; t < NUM_TEAMS; t++)			{				// draw box				CUIRect Rect = {Whole-ScoreWidthMax-ImageSize-2*Split, StartY+t*20, ScoreWidthMax+ImageSize+2*Split, 18.0f};				Graphics()->BlendNormal();				RenderTools()->DrawUIRect(&Rect, t == 0 ? vec4(1.0f, 0.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 1.0f, 0.25f), CUI::CORNER_L, 5.0f);				// draw score				TextRender()->Text(0, Whole-ScoreWidthMax+(ScoreWidthMax-aScoreTeamWidth[t])/2-Split, StartY+t*20, 14.0f, aScoreTeam[t], -1.0f);				if(GameFlags&GAMEFLAG_SURVIVAL)				{					// draw number of alive players					char aBuf[32];					str_format(aBuf, sizeof(aBuf), m_pClient->m_Snap.m_AliveCount[t]==1 ? Localize("%d player left") : Localize("%d players left"),								m_pClient->m_Snap.m_AliveCount[t]);					float w = TextRender()->TextWidth(0, 8.0f, aBuf, -1, -1.0f);					TextRender()->Text(0, min(Whole-w-1.0f, Whole-ScoreWidthMax-ImageSize-2*Split), StartY+(t+1)*20.0f-3.0f, 8.0f, aBuf, -1.0f);				}				StartY += 8.0f;			}			if(GameFlags&GAMEFLAG_FLAGS && m_pClient->m_Snap.m_pGameDataFlag)			{				int FlagCarrier[2] = { m_pClient->m_Snap.m_pGameDataFlag->m_FlagCarrierRed, m_pClient->m_Snap.m_pGameDataFlag->m_FlagCarrierBlue };				int FlagDropTick[2] = { m_pClient->m_Snap.m_pGameDataFlag->m_FlagDropTickRed, m_pClient->m_Snap.m_pGameDataFlag->m_FlagDropTickBlue };				StartY = 229.0f;				for(int t = 0; t < 2; t++)				{					int BlinkTimer = (FlagDropTick[t] != 0 && (Client()->GameTick()-FlagDropTick[t])/Client()->GameTickSpeed() >= 25) ? 10 : 20;					if(FlagCarrier[t] == FLAG_ATSTAND || (FlagCarrier[t] == FLAG_TAKEN && ((Client()->GameTick()/BlinkTimer)&1)))					{						// draw flag						Graphics()->BlendNormal();						Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);						Graphics()->QuadsBegin();						RenderTools()->SelectSprite(t==0?SPRITE_FLAG_RED:SPRITE_FLAG_BLUE);						IGraphics::CQuadItem QuadItem(Whole-ScoreWidthMax-ImageSize, StartY+1.0f+t*20, ImageSize/2, ImageSize);						Graphics()->QuadsDrawTL(&QuadItem, 1);						Graphics()->QuadsEnd();					}					else if(FlagCarrier[t] >= 0)					{						// draw name of the flag holder						int ID = FlagCarrier[t]%MAX_CLIENTS;						char aName[64];						str_format(aName, sizeof(aName), "%s", g_Config.m_ClShowsocial ? m_pClient->m_aClients[ID].m_aName : "");						float w = TextRender()->TextWidth(0, 8.0f, aName, -1, -1.0f) + RenderTools()->GetClientIdRectSize(8.0f);						CTextCursor Cursor;						float x = min(Whole-w-1.0f, Whole-ScoreWidthMax-ImageSize-2*Split);						float y = StartY+(t+1)*20.0f-3.0f;						TextRender()->SetCursor(&Cursor, x, y, 8.0f, TEXTFLAG_RENDER);						RenderTools()->DrawClientID(TextRender(), &Cursor, ID);						TextRender()->TextEx(&Cursor, aName, -1);						// draw tee of the flag holder						CTeeRenderInfo Info = m_pClient->m_aClients[ID].m_RenderInfo;						Info.m_Size = 18.0f;						RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1,0),							vec2(Whole-ScoreWidthMax-Info.m_Size/2-Split, StartY+1.0f+Info.m_Size/2+t*20));					}					StartY += 8.0f;				}			}		}		else		{			int Local = -1;			int aPos[2] = { 1, 2 };			CGameClient::CPlayerInfoItem aPlayerInfo[2] = {{0}};			int i = 0;			for(int t = 0; t < 2 && i < MAX_CLIENTS && m_pClient->m_Snap.m_aInfoByScore[i].m_pPlayerInfo; ++i)			{				if(m_pClient->m_aClients[m_pClient->m_Snap.m_aInfoByScore[i].m_ClientID].m_Team != TEAM_SPECTATORS)				{					aPlayerInfo[t] = m_pClient->m_Snap.m_aInfoByScore[i];					if(aPlayerInfo[t].m_ClientID == m_pClient->m_LocalClientID)						Local = t;//.........这里部分代码省略.........
开发者ID:BotoX,项目名称:teeworlds,代码行数:101,


示例23: Base

////////////////////////////////////////////////////////////// WaitingForTurnData////////////////////////////////////////////////////////////WaitingForTurnData::WaitingForTurnData(my_context ctx) :    Base(ctx){    if (TRACE_EXECUTION) DebugLogger() << "(HumanClientFSM) WaitingForTurnData";    Client().GetClientUI()->GetMapWnd()->EnableOrderIssuing(false);}
开发者ID:Ouaz,项目名称:freeorion,代码行数:9,



注:本文中的Client函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ClientBegin函数代码示例
C++ ClearUpdateMask函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。