diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index eae5ef3ae..925904721 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -478,7 +478,6 @@ void CClient::EnterGame() void CClient::Connect(const char *pAddress) { char aBuf[512]; - const char *pPortStr = 0; int Port = 8303; Disconnect(); @@ -494,18 +493,18 @@ void CClient::Connect(const char *pAddress) { if(aBuf[k] == ':') { - pPortStr = &(aBuf[k+1]); + Port = str_toint(aBuf+k+1); aBuf[k] = 0; break; } } - if(pPortStr) - Port = str_toint(pPortStr); - // TODO: IPv6 support if(net_host_lookup(aBuf, &m_ServerAddress, NETTYPE_IPV4) != 0) + { dbg_msg("client", "could not find the address of %s, connecting to localhost", aBuf); + net_host_lookup("localhost", &m_ServerAddress, NETTYPE_IPV4); + } m_RconAuthed = 0; m_ServerAddress.port = Port; diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index f3dddac7a..42f68978b 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -712,6 +712,8 @@ void CMenus::OnInit() if(g_Config.m_ClShowWelcome) m_Popup = POPUP_FIRST_LAUNCH; g_Config.m_ClShowWelcome = 0; + + Console()->Chain("add_favorite", ConchainServerbrowserUpdate, this); } void CMenus::PopupMessage(const char *pTopic, const char *pBody, const char *pButton) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 9ea9c6eff..3ad737e55 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -191,6 +191,7 @@ class CMenus : public CComponent void RenderServerbrowserServerDetail(CUIRect View); void RenderServerbrowserFilters(CUIRect View); void RenderServerbrowser(CUIRect MainView); + static void ConchainServerbrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); // found in menus_settings.cpp void RenderSettingsGeneral(CUIRect MainView); diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 32243a2a9..7d9c9d7ee 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -566,7 +566,8 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View) Row.VSplitLeft(25.0f, 0x0, &Row); CTextCursor Cursor; - TextRender()->SetCursor(&Cursor, Row.x, Row.y, 12.0f, TEXTFLAG_RENDER); + TextRender()->SetCursor(&Cursor, Row.x, Row.y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = Row.w; const char *pName = pSelectedServer->m_aPlayers[i].m_aName; if(g_Config.m_BrFilterString[0]) @@ -709,3 +710,10 @@ void CMenus::RenderServerbrowser(CUIRect MainView) UI()->DoLabel(&Button, Localize("Host address"), 14.0f, -1); } } + +void CMenus::ConchainServerbrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) +{ + pfnCallback(pResult, pCallbackUserData); + if(pResult->NumArguments() && g_Config.m_UiPage == PAGE_FAVORITES && ((CMenus *)pUserData)->Client()->State() == IClient::STATE_OFFLINE) + ((CMenus *)pUserData)->ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES); +} diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 80330e9cb..9558c840d 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -226,7 +226,10 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch str_format(aBuf, sizeof(aBuf), "%4d", pInfo->m_Score); TextRender()->Text(0, x+60-TextRender()->TextWidth(0, FontSize,aBuf,-1), y, FontSize, aBuf, -1); - TextRender()->Text(0, x+128, y, FontSize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1); + float FontSizeName = FontSize; + while(TextRender()->TextWidth(0, FontSizeName, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1) > w-200) + --FontSizeName; + TextRender()->Text(0, x+128, y+(FontSize-FontSizeName)/2, FontSizeName, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1); str_format(aBuf, sizeof(aBuf), "%4d", pInfo->m_Latency); float tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index d59a7a040..a3f618abe 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -545,9 +545,15 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) { if(m_SuppressEvents) return; - + + // don't enqueue pseudo-global sounds from demos (created by PlayAndRecord) CNetMsg_Sv_SoundGlobal *pMsg = (CNetMsg_Sv_SoundGlobal *)pRawMsg; - g_GameClient.m_pSounds->Enqueue(pMsg->m_Soundid); + 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)); } } diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index da97ed61d..015b9946d 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -833,9 +833,9 @@ void CEditor::DoQuad(CQuad *q, int Index) float CenterX = fx2f(q->m_aPoints[4].x); float CenterY = fx2f(q->m_aPoints[4].y); - float dx = (CenterX - wx); - float dy = (CenterY - wy); - if(dx*dx+dy*dy < 10*10) + float dx = (CenterX - wx)/m_WorldZoom; + float dy = (CenterY - wy)/m_WorldZoom; + if(dx*dx+dy*dy < 50) UI()->SetHotItem(pId); // draw selection background @@ -939,7 +939,7 @@ void CEditor::DoQuad(CQuad *q, int Index) else Graphics()->SetColor(0,1,0,1); - IGraphics::CQuadItem QuadItem(CenterX, CenterY, 5.0f, 5.0f); + IGraphics::CQuadItem QuadItem(CenterX, CenterY, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom); Graphics()->QuadsDraw(&QuadItem, 1); } @@ -953,9 +953,9 @@ void CEditor::DoQuadPoint(CQuad *q, int QuadIndex, int v) float px = fx2f(q->m_aPoints[v].x); float py = fx2f(q->m_aPoints[v].y); - float dx = (px - wx); - float dy = (py - wy); - if(dx*dx+dy*dy < 10*10) + float dx = (px - wx)/m_WorldZoom; + float dy = (py - wy)/m_WorldZoom; + if(dx*dx+dy*dy < 50) UI()->SetHotItem(pId); // draw selection background @@ -1084,7 +1084,7 @@ void CEditor::DoQuadPoint(CQuad *q, int QuadIndex, int v) else Graphics()->SetColor(1,0,0,1); - IGraphics::CQuadItem QuadItem(px, py, 5.0f, 5.0f); + IGraphics::CQuadItem QuadItem(px, py, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom); Graphics()->QuadsDraw(&QuadItem, 1); } @@ -1674,17 +1674,18 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) if(ValidGroup && m_SelectedLayer >= 0 && m_SelectedLayer < m_Map.m_lGroups[m_SelectedGroup]->m_lLayers.size()) ValidLayer = 1; - int Num = (int)(View.h/16.0f); + float LayersHeight = 12.0f; // Height of AddGroup button static int s_ScrollBar = 0; static float s_ScrollValue = 0; - int LayerNum = 0; for(int g = 0; g < m_Map.m_lGroups.size(); g++) - LayerNum += m_Map.m_lGroups[g]->m_lLayers.size() + 1; + // Each group is 19.0f + // Each layer is 14.0f + LayersHeight += 19.0f + m_Map.m_lGroups[g]->m_lLayers.size() * 14.0f; - int ScrollNum = LayerNum-Num+10; + float ScrollDifference = LayersHeight - LayersBox.h; - if(LayerNum > Num) // Do we even need a scrollbar? + if(LayersHeight > LayersBox.h) // Do we even need a scrollbar? { CUIRect Scroll; LayersBox.VSplitRight(15.0f, &LayersBox, &Scroll); @@ -1693,12 +1694,12 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) s_ScrollValue = UiDoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); } - int LayerStartAt = (int)(ScrollNum*s_ScrollValue); - if(LayerStartAt < 0) - LayerStartAt = 0; + float LayerStartAt = ScrollDifference * s_ScrollValue; + if(LayerStartAt < 0.0f) + LayerStartAt = 0.0f; - int LayerStopAt = LayerStartAt+Num; - int LayerCur = 0; + float LayerStopAt = LayersHeight - ScrollDifference * (1 - s_ScrollValue); + float LayerCur = 0; // render layers { @@ -1706,9 +1707,9 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { if(LayerCur > LayerStopAt) break; - else if(LayerCur + m_Map.m_lGroups[g]->m_lLayers.size() + 1 < LayerStartAt) + else if(LayerCur + m_Map.m_lGroups[g]->m_lLayers.size() * 14.0f + 19.0f < LayerStartAt) { - LayerCur += m_Map.m_lGroups[g]->m_lLayers.size() + 1; + LayerCur += m_Map.m_lGroups[g]->m_lLayers.size() * 14.0f + 19.0f; continue; } @@ -1733,13 +1734,15 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) } LayersBox.HSplitTop(2.0f, &Slot, &LayersBox); } - LayerCur++; + LayerCur += 14.0f; for(int i = 0; i < m_Map.m_lGroups[g]->m_lLayers.size(); i++) { - if(LayerCur < LayerStartAt || LayerCur > LayerStopAt) + if(LayerCur > LayerStopAt) + break; + else if(LayerCur < LayerStartAt) { - LayerCur++; + LayerCur += 14.0f; continue; } @@ -1762,10 +1765,12 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 150, PopupLayer); } - LayerCur++; + LayerCur += 14.0f; LayersBox.HSplitTop(2.0f, &Slot, &LayersBox); } - LayersBox.HSplitTop(5.0f, &Slot, &LayersBox); + if(LayerCur > LayerStartAt && LayerCur < LayerStopAt) + LayersBox.HSplitTop(5.0f, &Slot, &LayersBox); + LayerCur += 5.0f; } } @@ -1780,9 +1785,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) m_SelectedGroup = m_Map.m_lGroups.size()-1; } } - - //LayersBox.HSplitTop(5.0f, &Slot, &LayersBox); - } static void ExtractName(const char *pFileName, char *pName) @@ -1962,14 +1964,12 @@ void CEditor::SortImages() void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { - int Num = (int)(View.h/15.0f); static int s_ScrollBar = 0; static float s_ScrollValue = 0; + float ImagesHeight = 30.0f + 14.0f * m_Map.m_lImages.size() + 27.0f; + float ScrollDifference = ImagesHeight - ToolBox.h; - int ImageNum = m_Map.m_lImages.size(); - int ScrollNum = ImageNum-Num+10; - - if(ImageNum > Num) // Do we even need a scrollbar? + if(ImagesHeight > ToolBox.h) // Do we even need a scrollbar? { CUIRect Scroll; ToolBox.VSplitRight(15.0f, &ToolBox, &Scroll); @@ -1978,12 +1978,12 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) s_ScrollValue = UiDoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); } - int ImageStartAt = (int)(ScrollNum*s_ScrollValue); - if(ImageStartAt < 0) - ImageStartAt = 0; + float ImageStartAt = ScrollDifference * s_ScrollValue; + if(ImageStartAt < 0.0f) + ImageStartAt = 0.0f; - int ImageStopAt = ImageStartAt+Num; - int ImageCur = 0; + float ImageStopAt = ImagesHeight - ScrollDifference * (1 - s_ScrollValue); + float ImageCur = 0.0f; for(int e = 0; e < 2; e++) // two passes, first embedded, then external { @@ -2000,7 +2000,7 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) else UI()->DoLabel(&Slot, Localize("External"), 12.0f, 0); } - ImageCur++; + ImageCur += 15.0f; for(int i = 0; i < m_Map.m_lImages.size(); i++) { @@ -2014,10 +2014,10 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) break; else if(ImageCur < ImageStartAt) { - ImageCur++; + ImageCur += 14.0f; continue; } - ImageCur++; + ImageCur += 14.0f; char aBuf[128]; str_copy(aBuf, m_Map.m_lImages[i]->m_aName, sizeof(aBuf)); @@ -2055,6 +2055,9 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) } } + if(ImageCur + 27.0f > ImageStopAt) + return; + CUIRect Slot; ToolBox.HSplitTop(5.0f, &Slot, &ToolBox); @@ -2585,12 +2588,19 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) } else { - pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY*ValueScale); + if((Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL))) + pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY*0.001f); + else + pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY*ValueScale); + if(Input()->KeyPressed(KEY_LSHIFT) || Input()->KeyPressed(KEY_RSHIFT)) { if(i != 0) { - pEnvelope->m_lPoints[i].m_Time += (int)((m_MouseDeltaX*TimeScale)*1000.0f); + if((Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL))) + pEnvelope->m_lPoints[i].m_Time += (int)((m_MouseDeltaX)); + else + pEnvelope->m_lPoints[i].m_Time += (int)((m_MouseDeltaX*TimeScale)*1000.0f); if(pEnvelope->m_lPoints[i].m_Time < pEnvelope->m_lPoints[i-1].m_Time) pEnvelope->m_lPoints[i].m_Time = pEnvelope->m_lPoints[i-1].m_Time + 1; if(i+1 != pEnvelope->m_lPoints.size() && pEnvelope->m_lPoints[i].m_Time > pEnvelope->m_lPoints[i+1].m_Time) @@ -2617,7 +2627,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) ColorMod = 100.0f; Graphics()->SetColor(1,0.75f,0.75f,1); - m_pTooltip = Localize("Left mouse to drag. Hold shift to alter time point aswell. Right click to delete."); + m_pTooltip = Localize("Left mouse to drag. Hold ctfl to be more precise. Hold shift to alter time point aswell. Right click to delete."); } if(UI()->ActiveItem() == pId || UI()->HotItem() == pId) diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp index 001a7249c..19b0af26c 100644 --- a/src/game/editor/ed_popups.cpp +++ b/src/game/editor/ed_popups.cpp @@ -300,9 +300,9 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View) }; CProperty aProps[] = { - {Localize("Pos. Env"), pQuad->m_PosEnv, PROPTYPE_INT_STEP, -1, pEditor->m_Map.m_lEnvelopes.size()}, + {Localize("Pos. Env"), pQuad->m_PosEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1}, {Localize("Pos. TO"), pQuad->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000}, - {Localize("Color Env"), pQuad->m_ColorEnv, PROPTYPE_INT_STEP, -1, pEditor->m_Map.m_lEnvelopes.size()}, + {Localize("Color Env"), pQuad->m_ColorEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1}, {Localize("Color TO"), pQuad->m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000}, {0}, @@ -312,9 +312,9 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View) int NewVal = 0; int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal); - if(Prop == PROP_POS_ENV) pQuad->m_PosEnv = clamp(NewVal, -1, pEditor->m_Map.m_lEnvelopes.size()-1); + if(Prop == PROP_POS_ENV) pQuad->m_PosEnv = clamp(NewVal-1, -1, pEditor->m_Map.m_lEnvelopes.size()-1); if(Prop == PROP_POS_ENV_OFFSET) pQuad->m_PosEnvOffset = NewVal; - if(Prop == PROP_COLOR_ENV) pQuad->m_ColorEnv = clamp(NewVal, -1, pEditor->m_Map.m_lEnvelopes.size()-1); + if(Prop == PROP_COLOR_ENV) pQuad->m_ColorEnv = clamp(NewVal-1, -1, pEditor->m_Map.m_lEnvelopes.size()-1); if(Prop == PROP_COLOR_ENV_OFFSET) pQuad->m_ColorEnvOffset = NewVal; return 0; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index c2bb9dc8e..76eba7ed7 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -683,6 +683,13 @@ void CCharacter::Tick() Die(m_pPlayer->GetCID(), WEAPON_WORLD); } + // kill player when leaving gamelayer + if((int)m_Pos.x/32 < -200 || (int)m_Pos.x/32 > GameServer()->Collision()->GetWidth()+200 || + (int)m_Pos.y/32 < -200 || (int)m_Pos.y/32 > GameServer()->Collision()->GetHeight()+200) + { + Die(m_pPlayer->GetCID(), WEAPON_WORLD); + } + // handle Weapons HandleWeapons();