Conflicts:
	data/languages/german.txt
	src/game/client/components/scoreboard.cpp
	src/game/editor/ed_layer_tiles.cpp
	src/game/server/entities/character.cpp
	src/game/server/gamecontext.cpp
	src/game/server/gamecontroller.cpp
	src/game/variables.h
This commit is contained in:
GreYFoXGTi 2011-01-04 22:30:15 +02:00
commit c5648311ed
30 changed files with 315 additions and 295 deletions

View file

@ -1,4 +1,3 @@
##### translated strings #####
%d of %d servers, %d players
@ -76,6 +75,12 @@ As this is the first time you launch the game, please enter your nick name below
Aspect ratio
== Beeldverhouding
Automatically record demos
== Automatisch demo's opnemen
Automatically take game over screenshot
== Automatisch schermafbeeldingen nemen
Blue team
== Blauwe team
@ -412,6 +417,9 @@ Layers
Left
== Links
left
== nog
Left mouse button to move. Hold shift to move pivot. Hold ctrl to rotate.
== Linkermuisknop om te bewegen. Houd shift ingedrukt om te roteren. Houd ctrl ingedrukt om te draaien.
@ -449,9 +457,21 @@ Make external
Map
== Kaart
Max demos
== Maximaal aantal demo's
Max Screenshots
== Maximaal aantal schermafbeeldingen
Maximum ping:
== Hoogste ping:
minute
== minuut
minutes
== minuten
Miscellaneous
== Diverse
@ -468,7 +488,7 @@ Movement
== Bewegen
Mute when not active
== Demp, waneer niet actief
== Dempen wanneer inactief
Name
== Naam
@ -497,6 +517,9 @@ Nickname
No
== Nee
no limit
== ongelimiteerd
No password
== Geen wachtwoord
@ -597,7 +620,7 @@ Quick search:
== Snel zoeken:
Quit
== Stoppen
== Afsluiten
REC
== REC
@ -708,7 +731,13 @@ Scoreboard
== Scorebord
Screenshot
== Screenshot
== Schermafbeelding
second
== seconde
seconds
== seconden
Select group. Right click for properties.
== Kies een groep. Rechtermuisknop voor eigenschappen.
@ -934,36 +963,6 @@ ZO
##### needs translation #####
Automatically record demos
==
Automatically take game over screenshot
==
Max Screenshots
==
Max demos
==
left
==
minute
==
minutes
==
no limit
==
second
==
seconds
==
##### old translations #####

View file

@ -76,6 +76,12 @@ As this is the first time you launch the game, please enter your nick name below
Aspect ratio
== Seitenverhältnis
Automatically record demos
== Automatisch Demos aufnehmen
Automatically take game over screenshot
== Automatisch am Ende einer Runde ein Bildschirmfoto erstellen
Blue team
== Blaues Team
@ -448,6 +454,12 @@ Make external
Map
== Karte
Max Screenshots
== Maximale Bildschirmfotos
Max demos
== Maximale Demos
Maximum ping:
== Maximaler Ping:
@ -931,40 +943,28 @@ ZO
[ctrl+p] Toggles proof borders. These borders represent what a player maximum can see.
== [Strg+P] Schaltet Testrahmen um. Diese Rahmen zeigen, wie viel der Spieler höchstens sehen kann.
Loading DDRace Client
== Lade DDRace Client
left
== noch
minute
== Minute
minutes
== Minuten
no limit
== Keine Begrenzung
second
== Sekunde
seconds
== Sekunden
##### needs translation #####
Automatically record demos
==
Automatically take game over screenshot
==
Max Screenshots
==
Max demos
==
left
==
minute
==
minutes
==
no limit
==
second
==
seconds
==
##### old translations #####
Loading DDRace Client
== Lade DDRace Client

View file

@ -14,7 +14,14 @@ RawHeader = '''
enum
{
INPUT_STATE_MASK=0x3f,
INPUT_STATE_MASK=0x3f
};
enum
{
TEAM_SPECTATORS=-1,
TEAM_RED,
TEAM_BLUE
};
'''
@ -83,7 +90,7 @@ Objects = [
NetIntAny("m_X"),
NetIntAny("m_Y"),
NetIntRange("m_Team", 0, 1),
NetIntRange("m_Team", 'TEAM_RED', 'TEAM_BLUE'),
NetIntRange("m_CarriedBy", -2, 'MAX_CLIENTS-1')
]),
@ -141,7 +148,7 @@ Objects = [
NetObject("PlayerInfo", [
NetIntRange("m_Local", 0, 1),
NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_Team", -1, 1),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetIntAny("m_Score"),
NetIntAny("m_Latency"),
@ -204,7 +211,7 @@ Messages = [
]),
NetMessage("Sv_Chat", [
NetIntRange("m_Team", -1, 1),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetIntRange("m_Cid", -1, 'MAX_CLIENTS-1'),
NetString("m_pMessage"),
]),
@ -260,7 +267,7 @@ Messages = [
]),
NetMessage("Cl_SetTeam", [
NetIntRange("m_Team", -1, 1),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
]),
NetMessage("Cl_StartInfo", [

View file

@ -32,6 +32,6 @@ for filename in sys.argv[1:]:
hash = hashlib.md5(f).hexdigest().lower()[16:]
# TODO: refactor hash that is equal to the 0.5 hash, remove when we
# TODO: remove when we don't need it any more
if hash == "7e33344691ca8a61":
if hash == "026b8eceb4cdd369":
hash = "b67d1f1a1eea234e"
print '#define GAME_NETVERSION_HASH "%s"' % hash

View file

@ -1813,8 +1813,6 @@ void CClient::Run()
if(!LoadData())
return;
DemoRecorder_Init();
GameClient()->OnInit();
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion());
@ -2138,12 +2136,6 @@ void CClient::Con_Play(IConsole::IResult *pResult, void *pUserData, int ClientID
pSelf->DemoPlayer_Play(pResult->GetString(0), IStorage::TYPE_ALL);
}
void CClient::DemoRecorder_Init()
{
if(!Storage()->CreateFolder("demos/auto", IStorage::TYPE_SAVE))
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demorec/record", "unable to create auto record folder");
}
void CClient::DemoRecorder_Start(const char *pFilename, bool WithTimestamp)
{
if(State() != IClient::STATE_ONLINE)

View file

@ -315,7 +315,6 @@ public:
void RegisterCommands();
const char *DemoPlayer_Play(const char *pFilename, int StorageType);
void DemoRecorder_Init();
void DemoRecorder_Start(const char *pFilename, bool WithTimestamp);
void DemoRecorder_HandleAutoStart();
void DemoRecorder_Stop();

View file

@ -30,7 +30,7 @@ enum
};
static int aFontSizes[] = {8,9,10,11,12,13,14,15,16,17,18,19,20,36};
static int aFontSizes[] = {8,9,10,11,12,13,14,15,16,17,18,19,20,36,64};
#define NUM_FONT_SIZES (sizeof(aFontSizes)/sizeof(int))
struct CFontChar
@ -178,6 +178,15 @@ class CTextRender : public IEngineTextRender
mem_free(pMem);
}
int AdjustOutlineThicknessToFontSize(int OutlineThickness, int FontSize)
{
if(FontSize > 36)
OutlineThickness *= 4;
else if(FontSize >= 18)
OutlineThickness *= 2;
return OutlineThickness;
}
void IncreaseTextureSize(CFontSizeData *pSizeData)
{
if(pSizeData->m_TextureWidth < pSizeData->m_TextureHeight)
@ -191,14 +200,12 @@ class CTextRender : public IEngineTextRender
// TODO: Refactor: move this into a pFont class
void InitIndex(CFont *pFont, int Index)
{
int OutlineThickness = 1;
CFontSizeData *pSizeData = &pFont->m_aSizes[Index];
pSizeData->m_FontSize = aFontSizes[Index];
FT_Set_Pixel_Sizes(pFont->m_FtFace, 0, pSizeData->m_FontSize);
if(pSizeData->m_FontSize >= 18)
OutlineThickness = 2;
int OutlineThickness = AdjustOutlineThicknessToFontSize(1, pSizeData->m_FontSize);
{
unsigned GlyphIndex;
@ -290,7 +297,6 @@ class CTextRender : public IEngineTextRender
int SlotW = pSizeData->m_TextureWidth / pSizeData->m_NumXChars;
int SlotH = pSizeData->m_TextureHeight / pSizeData->m_NumYChars;
int SlotSize = SlotW*SlotH;
int OutlineThickness = 1;
int x = 1;
int y = 1;
int px, py;
@ -311,8 +317,7 @@ class CTextRender : public IEngineTextRender
return -1;
// adjust spacing
if(pSizeData->m_FontSize >= 18)
OutlineThickness = 2;
int OutlineThickness = AdjustOutlineThicknessToFontSize(1, pSizeData->m_FontSize);
x += OutlineThickness;
y += OutlineThickness;

View file

@ -231,15 +231,15 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine)
}
else
{
if(m_pClient->m_aClients[ClientId].m_Team == -1)
m_aLines[m_CurrentLine].m_NameColor = -1;
if(m_pClient->m_aClients[ClientId].m_Team == TEAM_SPECTATORS)
m_aLines[m_CurrentLine].m_NameColor = TEAM_SPECTATORS;
if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS)
{
if(m_pClient->m_aClients[ClientId].m_Team == 0)
m_aLines[m_CurrentLine].m_NameColor = 0;
else if(m_pClient->m_aClients[ClientId].m_Team == 1)
m_aLines[m_CurrentLine].m_NameColor = 1;
if(m_pClient->m_aClients[ClientId].m_Team == TEAM_RED)
m_aLines[m_CurrentLine].m_NameColor = TEAM_RED;
else if(m_pClient->m_aClients[ClientId].m_Team == TEAM_BLUE)
m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE;
}
str_copy(m_aLines[m_CurrentLine].m_aName, m_pClient->m_aClients[ClientId].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName));
@ -353,11 +353,11 @@ void CChat::OnRender()
TextRender()->TextColor(1.0f, 1.0f, 0.5f, Blend); // system
else if(m_aLines[r].m_Team)
TextRender()->TextColor(0.45f, 0.9f, 0.45f, Blend); // team message
else if(m_aLines[r].m_NameColor == 0)
else if(m_aLines[r].m_NameColor == TEAM_RED)
TextRender()->TextColor(1.0f, 0.5f, 0.5f, Blend); // red
else if(m_aLines[r].m_NameColor == 1)
else if(m_aLines[r].m_NameColor == TEAM_BLUE)
TextRender()->TextColor(0.7f, 0.7f, 1.0f, Blend); // blue
else if(m_aLines[r].m_NameColor == -1)
else if(m_aLines[r].m_NameColor == TEAM_SPECTATORS)
TextRender()->TextColor(0.75f, 0.5f, 0.75f, Blend); // spectator
else
TextRender()->TextColor(0.8f, 0.8f, 0.8f, Blend);

View file

@ -87,10 +87,10 @@ void CHud::RenderScoreHud()
if(!(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver) && (GameFlags&GAMEFLAG_TEAMS))
{
char aScoreTeam[2][32];
str_format(aScoreTeam[0], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed);
str_format(aScoreTeam[1], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue);
float aScoreTeamWidth[2] = {TextRender()->TextWidth(0, 14.0f, aScoreTeam[0], -1), TextRender()->TextWidth(0, 14.0f, aScoreTeam[1], -1)};
float ScoreWidthMax = max(max(aScoreTeamWidth[0], aScoreTeamWidth[1]), TextRender()->TextWidth(0, 14.0f, "100", -1));
str_format(aScoreTeam[TEAM_RED], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed);
str_format(aScoreTeam[TEAM_BLUE], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue);
float aScoreTeamWidth[2] = {TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_RED], -1), TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_BLUE], -1)};
float ScoreWidthMax = max(max(aScoreTeamWidth[TEAM_RED], aScoreTeamWidth[TEAM_BLUE]), TextRender()->TextWidth(0, 14.0f, "100", -1));
float Split = 3.0f;
float ImageSize = GameFlags&GAMEFLAG_FLAGS ? 16.0f : Split;
@ -199,7 +199,7 @@ void CHud::RenderTeambalanceWarning()
bool Flash = time_get()/(time_freq()/2)%2 == 0;
if (m_pClient->m_Snap.m_pGameobj && (m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS) != 0)
{
int TeamDiff = m_pClient->m_Snap.m_aTeamSize[0]-m_pClient->m_Snap.m_aTeamSize[1];
int TeamDiff = m_pClient->m_Snap.m_aTeamSize[TEAM_RED]-m_pClient->m_Snap.m_aTeamSize[TEAM_BLUE];
if (g_Config.m_ClWarningTeambalance && (TeamDiff >= 2 || TeamDiff <= -2))
{
const char *pText = Localize("Please balance teams!");
@ -411,7 +411,7 @@ void CHud::OnRender()
m_Width = 300*Graphics()->ScreenAspect();
bool Spectate = false;
if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team == -1)
if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team == TEAM_SPECTATORS)
Spectate = true;
if(m_pClient->m_Snap.m_pLocalCharacter && !Spectate && !(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)) {

View file

@ -161,7 +161,7 @@ void CItems::RenderFlag(const CNetObj_Flag *pPrev, const CNetObj_Flag *pCurrent)
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
Graphics()->QuadsBegin();
if(pCurrent->m_Team == 0) // red team
if(pCurrent->m_Team == TEAM_RED)
RenderTools()->SelectSprite(SPRITE_FLAG_RED);
else
RenderTools()->SelectSprite(SPRITE_FLAG_BLUE);

View file

@ -51,10 +51,9 @@ void CKillMessages::OnRender()
float StartX = Width*1.5f-10.0f;
float y = 20.0f;
for(int i = 0; i < MAX_KILLMSGS; i++)
for(int i = 1; i <= MAX_KILLMSGS; i++)
{
int r = (m_KillmsgCurrent+i+1)%MAX_KILLMSGS;
int r = (m_KillmsgCurrent+i)%MAX_KILLMSGS;
if(Client()->GameTick() > m_aKillmsgs[r].m_Tick+50*10)
continue;
@ -79,7 +78,7 @@ void CKillMessages::OnRender()
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
Graphics()->QuadsBegin();
if(m_aKillmsgs[r].m_VictimTeam == 0)
if(m_aKillmsgs[r].m_VictimTeam == TEAM_RED)
RenderTools()->SelectSprite(SPRITE_FLAG_BLUE);
else
RenderTools()->SelectSprite(SPRITE_FLAG_RED);
@ -116,7 +115,7 @@ void CKillMessages::OnRender()
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
Graphics()->QuadsBegin();
if(m_aKillmsgs[r].m_KillerTeam == 0)
if(m_aKillmsgs[r].m_KillerTeam == TEAM_RED)
RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X);
else
RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);

View file

@ -182,12 +182,13 @@ void CMapLayers::OnRender()
Graphics()->TextureSet(-1);
else
Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image));
CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);
Graphics()->BlendNone();
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f);
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
Graphics()->BlendNormal();
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
}
else if(pLayer->m_Type == LAYERTYPE_QUADS)
{

View file

@ -41,44 +41,6 @@ float CMenus::ms_FontmodHeight = 0.8f;
IInput::CEvent CMenus::m_aInputEvents[MAX_INPUTEVENTS];
int CMenus::m_NumInputEvents;
inline float HueToRgb(float v1, float v2, float h)
{
if(h < 0) h += 1;
if(h > 1) h -= 1;
if((6 * h) < 1) return v1 + ( v2 - v1 ) * 6 * h;
if((2 * h) < 1) return v2;
if((3 * h) < 2) return v1 + ( v2 - v1 ) * ((2.0f/3.0f) - h) * 6;
return v1;
}
inline vec3 HslToRgb(vec3 In)
{
float v1, v2;
vec3 Out;
if(In.s == 0)
{
Out.r = In.l;
Out.g = In.l;
Out.b = In.l;
}
else
{
if(In.l < 0.5f)
v2 = In.l * (1 + In.s);
else
v2 = (In.l+In.s) - (In.s*In.l);
v1 = 2 * In.l - v2;
Out.r = HueToRgb(v1, v2, In.h + (1.0f/3.0f));
Out.g = HueToRgb(v1, v2, In.h);
Out.b = HueToRgb(v1, v2, In.h - (1.0f/3.0f));
}
return Out;
}
CMenus::CMenus()
{

View file

@ -37,40 +37,40 @@ void CMenus::RenderGame(CUIRect MainView)
if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pGameobj)
{
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != -1)
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS)
{
MainView.VSplitLeft(10.0f, &Button, &MainView);
MainView.VSplitLeft(120.0f, &Button, &MainView);
static int s_SpectateButton = 0;
if(DoButton_Menu(&s_SpectateButton, Localize("Spectate"), 0, &Button))
{
m_pClient->SendSwitchTeam(-1);
m_pClient->SendSwitchTeam(TEAM_SPECTATORS);
SetActive(false);
}
}
if(m_pClient->m_Snap.m_pGameobj->m_Flags & GAMEFLAG_TEAMS)
{
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != 0)
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_RED)
{
MainView.VSplitLeft(10.0f, &Button, &MainView);
MainView.VSplitLeft(120.0f, &Button, &MainView);
static int s_SpectateButton = 0;
if(DoButton_Menu(&s_SpectateButton, Localize("Join red"), 0, &Button))
{
m_pClient->SendSwitchTeam(0);
m_pClient->SendSwitchTeam(TEAM_RED);
SetActive(false);
}
}
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != 1)
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_BLUE)
{
MainView.VSplitLeft(10.0f, &Button, &MainView);
MainView.VSplitLeft(120.0f, &Button, &MainView);
static int s_SpectateButton = 0;
if(DoButton_Menu(&s_SpectateButton, Localize("Join blue"), 0, &Button))
{
m_pClient->SendSwitchTeam(1);
m_pClient->SendSwitchTeam(TEAM_BLUE);
SetActive(false);
}
}

View file

@ -98,13 +98,25 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
if(DoButton_CheckBox(&g_Config.m_ClNameplates, Localize("Show name plates"), g_Config.m_ClNameplates, &Button))
g_Config.m_ClNameplates ^= 1;
//if(config.cl_nameplates)
LeftView.HSplitTop(20.0f, &Button, &LeftView);
if(g_Config.m_ClNameplates)
{
LeftView.HSplitTop(20.0f, &Button, &LeftView);
Button.VSplitLeft(15.0f, 0, &Button);
if(DoButton_CheckBox(&g_Config.m_ClNameplatesAlways, Localize("Always show name plates"), g_Config.m_ClNameplatesAlways, &Button))
g_Config.m_ClNameplatesAlways ^= 1;
// draw nameplates size slider
CUIRect Label;
LeftView.HSplitTop(20.0f, &Button, &LeftView);
Button.VSplitLeft(15.0f, 0, &Button);
Button.VSplitRight(10.0f, &Button, 0);
Button.VSplitLeft(140.0f, &Label, &Button);
Button.HMargin(2.0f, &Button);
UI()->DoLabel(&Label, Localize("Name plates size"), 13.0f, -1);
g_Config.m_ClNameplatesSize = (int)(DoScrollbarH(&g_Config.m_ClNameplatesSize, &Button, g_Config.m_ClNameplatesSize/100.0f)*100.0f+0.1f);
}
else
LeftView.HSplitTop(20.0f, &Button, &LeftView);
{
const CSkins::CSkin *pOwnSkin = m_pClient->m_pSkins->Get(max(0, m_pClient->m_pSkins->Find(g_Config.m_PlayerSkin)));

View file

@ -20,18 +20,28 @@ void CNamePlates::RenderNameplate(
vec2 Position = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), IntraTick);
float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;
// render name plate
if(!pPlayerInfo->m_Local)
{
//TextRender()->TextColor
float a = 1;
if(g_Config.m_ClNameplatesAlways == 0)
a = clamp(1-powf(distance(m_pClient->m_pControls->m_TargetPos, Position)/200.0f,16.0f), 0.0f, 1.0f);
const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientId].m_aName;
float tw = TextRender()->TextWidth(0, 28.0f, pName, -1);
TextRender()->TextColor(1,1,1,a);
TextRender()->Text(0, Position.x-tw/2.0f, Position.y-60, 28.0f, pName, -1);
float tw = TextRender()->TextWidth(0, FontSize, pName, -1);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, a);
if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS)
{
if(pPlayerInfo->m_Team == TEAM_RED)
TextRender()->TextColor(1.0f, 0.5f, 0.5f, a);
else if(pPlayerInfo->m_Team == TEAM_BLUE)
TextRender()->TextColor(0.7f, 0.7f, 1.0f, a);
}
TextRender()->Text(0, Position.x-tw/2.0f, Position.y-FontSize-38.0f, FontSize, pName, -1);
if(g_Config.m_Debug) // render client id when in debug aswell
{

View file

@ -105,7 +105,7 @@ void CScoreboard::RenderSpectators(float x, float y, float w)
if(Item.m_Type == NETOBJTYPE_PLAYERINFO)
{
const CNetObj_PlayerInfo *pInfo = (const CNetObj_PlayerInfo *)pData;
if(pInfo->m_Team == -1)
if(pInfo->m_Team == TEAM_SPECTATORS)
{
if(Count)
str_append(aBuffer, ", ", sizeof(aBuffer));
@ -150,7 +150,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
float tw = TextRender()->TextWidth(0, 48, pTitle, -1);
if(Team == -1)
if(Team == TEAM_SPECTATORS)
{
TextRender()->Text(0, x+w/2-tw/2, y, 48, pTitle, -1);
}
@ -161,7 +161,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
/*if(m_pClient->m_Snap.m_pGameobj) // This is Useless
{
char aBuf[128];
int Score = Team ? m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue : m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed;
int Score = Team == TEAM_RED ? m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed : m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue;
}*/
}
@ -288,7 +288,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
Graphics()->QuadsBegin();
if(pInfo->m_Team == 0) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X);
if(pInfo->m_Team == TEAM_RED) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X);
else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
float size = 64.0f;
@ -337,7 +337,7 @@ void CScoreboard::OnRender()
if(m_Active)
DoScoreBoard = true;
if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != -1)
if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS)
{
// we are not a spectator, check if we are ead
if(!m_pClient->m_Snap.m_pLocalCharacter || m_pClient->m_Snap.m_pLocalCharacter->m_Health < 0)
@ -383,8 +383,8 @@ void CScoreboard::OnRender()
TextRender()->Text(0, Width/2-w/2, 45, 92.0f, pText, -1);
}
RenderScoreboard(Width/2-w-20, 150.0f, w, 0, Localize("Red team"));
RenderScoreboard(Width/2 + 20, 150.0f, w, 1, Localize("Blue team"));
RenderScoreboard(Width/2-w-20, 150.0f, w, TEAM_RED, Localize("Red team"));
RenderScoreboard(Width/2 + 20, 150.0f, w, TEAM_BLUE, Localize("Blue team"));
}
RenderGoals(Width/2-w/2, 150+750+25, w);

View file

@ -140,45 +140,6 @@ int CSkins::Find(const char *pName)
return -1;
}
// these converter functions were nicked from some random internet pages
static float HueToRgb(float v1, float v2, float h)
{
if(h < 0) h += 1;
if(h > 1) h -= 1;
if((6 * h) < 1) return v1 + ( v2 - v1 ) * 6 * h;
if((2 * h) < 1) return v2;
if((3 * h) < 2) return v1 + ( v2 - v1 ) * ((2.0f/3.0f) - h) * 6;
return v1;
}
static vec3 HslToRgb(vec3 in)
{
float v1, v2;
vec3 Out;
if(in.s == 0)
{
Out.r = in.l;
Out.g = in.l;
Out.b = in.l;
}
else
{
if(in.l < 0.5f)
v2 = in.l * (1 + in.s);
else
v2 = (in.l+in.s) - (in.s*in.l);
v1 = 2 * in.l - v2;
Out.r = HueToRgb(v1, v2, in.h + (1.0f/3.0f));
Out.g = HueToRgb(v1, v2, in.h);
Out.b = HueToRgb(v1, v2, in.h - (1.0f/3.0f));
}
return Out;
}
vec3 CSkins::GetColorV3(int v)
{
return HslToRgb(vec3(((v>>16)&0xff)/255.0f, ((v>>8)&0xff)/255.0f, 0.5f+(v&0xff)/255.0f*0.5f));
@ -186,6 +147,6 @@ vec3 CSkins::GetColorV3(int v)
vec4 CSkins::GetColorV4(int v)
{
vec3 r = HslToRgb(vec3(((v>>16)&0xff)/255.0f, ((v>>8)&0xff)/255.0f, 0.5f+(v&0xff)/255.0f*0.5f));
vec3 r = GetColorV3(v);
return vec4(r.r, r.g, r.b, 1.0f);
}

View file

@ -728,7 +728,7 @@ void CGameClient::OnNewSnapshot()
// go trough all the items in the snapshot and gather the info we want
{
m_Snap.m_aTeamSize[0] = m_Snap.m_aTeamSize[1] = 0;
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++)
@ -789,12 +789,12 @@ void CGameClient::OnNewSnapshot()
m_Snap.m_LocalCid = Item.m_Id;
m_Snap.m_pLocalInfo = pInfo;
if (pInfo->m_Team == -1)
if(pInfo->m_Team == TEAM_SPECTATORS)
m_Snap.m_Spectate = true;
}
// calculate team-balance
if(pInfo->m_Team != -1)
if(pInfo->m_Team != TEAM_SPECTATORS)
m_Snap.m_aTeamSize[pInfo->m_Team]++;
}
@ -1002,7 +1002,7 @@ void CGameClient::CClientData::UpdateRenderInfo()
if(g_GameClient.m_Snap.m_pGameobj && g_GameClient.m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS)
{
const int TeamColors[2] = {65387, 10223467};
if(m_Team >= 0 && m_Team <= 1)
if(m_Team >= TEAM_RED && m_Team <= TEAM_BLUE)
{
m_RenderInfo.m_Texture = g_GameClient.m_pSkins->Get(m_SkinId)->m_ColorTexture;
m_RenderInfo.m_ColorBody = g_GameClient.m_pSkins->GetColorV4(TeamColors[m_Team]);

View file

@ -218,6 +218,31 @@ public:
class CScoreboard *m_pScoreboard;
};
inline float HueToRgb(float v1, float v2, float h)
{
if(h < 0.0f) h += 1;
if(h > 1.0f) h -= 1;
if((6.0f * h) < 1.0f) return v1 + (v2 - v1) * 6.0f * h;
if((2.0f * h) < 1.0f) return v2;
if((3.0f * h) < 2.0f) return v1 + (v2 - v1) * ((2.0f/3.0f) - h) * 6.0f;
return v1;
}
inline vec3 HslToRgb(vec3 HSL)
{
if(HSL.s == 0.0f)
return vec3(HSL.l, HSL.l, HSL.l);
else
{
float v2 = HSL.l < 0.5f ? HSL.l * (1.0f + HSL.s) : (HSL.l+HSL.s) - (HSL.s*HSL.l);
float v1 = 2.0f * HSL.l - v2;
return vec3(HueToRgb(v1, v2, HSL.h + (1.0f/3.0f)), HueToRgb(v1, v2, HSL.h), HueToRgb(v1, v2, HSL.h - (1.0f/3.0f)));
}
}
extern const char *Localize(const char *Str);
#endif

View file

@ -1887,7 +1887,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
m_SelectedGroup = g;
static int s_LayerPopupId = 0;
if(Result == 2)
UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupLayer);
UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 220, PopupLayer);
}
LayerCur += 14.0f;

View file

@ -406,6 +406,7 @@ public:
int m_Image;
int m_Width;
int m_Height;
CColor m_Color;
CTile *m_pTiles;
char m_aFileName[512];
};

View file

@ -283,11 +283,11 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
Item.m_Layer.m_Flags = pLayer->m_Flags;
Item.m_Layer.m_Type = pLayer->m_Type;
Item.m_Color.r = 255; // not in use right now
Item.m_Color.g = 255;
Item.m_Color.b = 255;
Item.m_Color.a = 255;
Item.m_ColorEnv = -1;
Item.m_Color.r = pLayer->m_Color.r;
Item.m_Color.g = pLayer->m_Color.g;
Item.m_Color.b = pLayer->m_Color.b;
Item.m_Color.a = pLayer->m_Color.a;
Item.m_ColorEnv = -1; // not in use right now
Item.m_ColorEnvOffset = 0;
Item.m_Width = pLayer->m_Width;
@ -570,6 +570,10 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
{
pTiles = new CLayerTiles(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles->m_pEditor = m_pEditor;
pTiles->m_Color.r = pTilemapItem->m_Color.r;
pTiles->m_Color.g = pTilemapItem->m_Color.g;
pTiles->m_Color.b = pTilemapItem->m_Color.b;
pTiles->m_Color.a = pTilemapItem->m_Color.a;
}
pLayer = pTiles;

View file

@ -22,6 +22,10 @@ CLayerTiles::CLayerTiles(int w, int h)
m_Image = -1;
m_TexId = -1;
m_Game = 0;
m_Color.r = 255;
m_Color.g = 255;
m_Color.b = 255;
m_Color.a = 255;
m_Tele = 0;
m_Speedup = 0;
m_Front = 0;
@ -42,7 +46,7 @@ void CLayerTiles::PrepareForSave()
for(int x = 0; x < m_Width; x++)
m_pTiles[y*m_Width+x].m_Flags &= TILEFLAG_VFLIP|TILEFLAG_HFLIP|TILEFLAG_ROTATE;
if(m_Image != -1)
if(m_Image != -1 && m_Color.a == 255)
{
for(int y = 0; y < m_Height; y++)
for(int x = 0; x < m_Width; x++)
@ -62,7 +66,8 @@ void CLayerTiles::Render()
if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size())
m_TexId = m_pEditor->m_Map.m_lImages[m_Image]->m_TexId;
Graphics()->TextureSet(m_TexId);
m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, vec4(1,1,1,1), LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT);
vec4 Color = vec4(m_Color.r/255.0f, m_Color.g/255.0f, m_Color.b/255.0f, m_Color.a/255.0f);
m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT);
if(m_Tele)
m_pEditor->RenderTools()->RenderTelemap(((CLayerTele*)this)->m_pTeleTile, m_Width, m_Height, 32.0f);
if(m_Speedup)
@ -343,13 +348,13 @@ void CLayerTiles::BrushFlipY()
void CLayerTiles::BrushRotate(float Amount)
{
int Rotation = (round(360.0f*Amount/(pi*2))/90)%4; // 0=0<EFBFBD>, 1=90<39>, 2=180<38>, 3=270<37>
int Rotation = (round(360.0f*Amount/(pi*2))/90)%4; // 0=0?, 1=90?, 2=180?, 3=270?
if(Rotation < 0)
Rotation +=4;
if(Rotation == 1 || Rotation == 3)
{
// 90<EFBFBD> rotation
// 90? rotation
CTile *pTempData = new CTile[m_Width*m_Height];
mem_copy(pTempData, m_pTiles, m_Width*m_Height*sizeof(CTile));
CTile *pDst = m_pTiles;
@ -453,38 +458,47 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
bool InGameGroup = !find_linear(m_pEditor->m_Map.m_pGameGroup->m_lLayers.all(), this).empty();
if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this)
InGameGroup = false;
static int s_ColclButton = 0;
if(m_pEditor->DoButton_Editor(&s_ColclButton, Localize("Clear collision"), InGameGroup?0:-1, &Button, 0, Localize("Removes collision from this layer")))
if(InGameGroup)
{
CLayerTiles *gl = m_pEditor->m_Map.m_pGameLayer;
int w = min(gl->m_Width, m_Width);
int h = min(gl->m_Height, m_Height);
for(int y = 0; y < h; y++)
for(int x = 0; x < w; x++)
static int s_ColclButton = 0;
if(m_pEditor->DoButton_Editor(&s_ColclButton, Localize("Clear collision"), 0, &Button, 0, Localize("Removes collision from this layer")))
{
CLayerTiles *gl = m_pEditor->m_Map.m_pGameLayer;
int w = min(gl->m_Width, m_Width);
int h = min(gl->m_Height, m_Height);
for(int y = 0; y < h; y++)
{
if(gl->m_pTiles[y*gl->m_Width+x].m_Index <= TILE_SOLID)
if(m_pTiles[y*m_Width+x].m_Index)
gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR;
for(int x = 0; x < w; x++)
{
if(gl->m_pTiles[y*gl->m_Width+x].m_Index <= TILE_SOLID)
{
if(m_pTiles[y*m_Width+x].m_Index)
gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR;
}
}
}
return 1;
}
static int s_ColButton = 0;
pToolBox->HSplitBottom(5.0f, pToolBox, &Button);
pToolBox->HSplitBottom(12.0f, pToolBox, &Button);
if(m_pEditor->DoButton_Editor(&s_ColButton, Localize("Make collision"), InGameGroup?0:-1, &Button, 0, Localize("Constructs collision from this layer")))
{
CLayerTiles *gl = m_pEditor->m_Map.m_pGameLayer;
int w = min(gl->m_Width, m_Width);
int h = min(gl->m_Height, m_Height);
for(int y = 0; y < h; y++)
for(int x = 0; x < w; x++)
return 1;
}
static int s_ColButton = 0;
pToolBox->HSplitBottom(5.0f, pToolBox, &Button);
pToolBox->HSplitBottom(12.0f, pToolBox, &Button);
if(m_pEditor->DoButton_Editor(&s_ColButton, Localize("Make collision"), 0, &Button, 0, Localize("Constructs collision from this layer")))
{
CLayerTiles *gl = m_pEditor->m_Map.m_pGameLayer;
int w = min(gl->m_Width, m_Width);
int h = min(gl->m_Height, m_Height);
for(int y = 0; y < h; y++)
{
if(gl->m_pTiles[y*gl->m_Width+x].m_Index <= TILE_SOLID)
gl->m_pTiles[y*gl->m_Width+x].m_Index = m_pTiles[y*m_Width+x].m_Index?TILE_SOLID:TILE_AIR;
for(int x = 0; x < w; x++)
{
if(gl->m_pTiles[y*gl->m_Width+x].m_Index <= TILE_SOLID)
gl->m_pTiles[y*gl->m_Width+x].m_Index = m_pTiles[y*m_Width+x].m_Index?TILE_SOLID:TILE_AIR;
}
}
return 1;
return 1;
}
}
enum
@ -493,19 +507,30 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
PROP_HEIGHT,
PROP_SHIFT,
PROP_IMAGE,
PROP_COLOR,
NUM_PROPS,
};
int Color = 0;
Color |= m_Color.r<<24;
Color |= m_Color.g<<16;
Color |= m_Color.b<<8;
Color |= m_Color.a;
CProperty aProps[] = {
{Localize("Width"), m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000},
{Localize("Height"), m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000},
{Localize("Shift"), 0, PROPTYPE_SHIFT, 0, 0},
{Localize("Image"), m_Image, PROPTYPE_IMAGE, 0, 0},
{Localize("Color"), Color, PROPTYPE_COLOR, 0, 0},
{0},
};
if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this) // remove the image from the selection if this is the game/tele/speedup/front/switch layer
if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this) // remove the image and color properties if this is the game/tele/speedup/front/switch layer
{
aProps[3].m_pName = 0;
aProps[4].m_pName = 0;
}
static int s_aIds[NUM_PROPS] = {0};
int NewVal = 0;
@ -527,6 +552,13 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
else
m_Image = NewVal%m_pEditor->m_Map.m_lImages.size();
}
else if(Prop == PROP_COLOR)
{
m_Color.r = (NewVal>>24)&0xff;
m_Color.g = (NewVal>>16)&0xff;
m_Color.b = (NewVal>>8)&0xff;
m_Color.a = NewVal&0xff;
}
return 0;
}

View file

@ -589,7 +589,7 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput));
if(m_NumInputs > 2 && m_pPlayer->GetTeam() != -1)
if(m_NumInputs > 2 && m_pPlayer->GetTeam() != TEAM_SPECTATORS)
{
HandleWeaponSwitch();
FireWeapon();
@ -1266,7 +1266,7 @@ void CCharacter::TickDefered()
if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Mask);
if(m_pPlayer->GetTeam() == -1)
if(m_pPlayer->GetTeam() == TEAM_SPECTATORS)
{
m_Pos.x = m_Input.m_TargetX;
m_Pos.y = m_Input.m_TargetY;

View file

@ -508,7 +508,7 @@ void CGameContext::OnTick()
bool aVoteChecked[MAX_CLIENTS] = {0};
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(!m_apPlayers[i] || (g_Config.m_SvSpectatorVotes == 0 && m_apPlayers[i]->GetTeam() == -1) || aVoteChecked[i]) // don't count in votes by spectators
if(!m_apPlayers[i] || (g_Config.m_SvSpectatorVotes == 0 && m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS) || aVoteChecked[i]) // don't count in votes by spectators
continue;
if(m_VoteKick &&
GetPlayerChar(m_VoteCreator) && GetPlayerChar(i) &&
@ -706,7 +706,7 @@ void CGameContext::OnSetAuthed(int client_id, int Level)
void CGameContext::OnClientConnected(int ClientId)
{
// Check which team the player should be on
const int StartTeam = g_Config.m_SvTournamentMode ? -1 : m_pController->GetAutoTeam(ClientId);
const int StartTeam = g_Config.m_SvTournamentMode ? TEAM_SPECTATORS : m_pController->GetAutoTeam(ClientId);
m_apPlayers[ClientId] = new(ClientId) CPlayer(this, ClientId, StartTeam);
//players[client_id].init(client_id);
@ -811,7 +811,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
int64 Now = Server()->Tick();
p->m_Last_VoteTry = Now;
if(g_Config.m_SvSpectatorVotes == 0 && p->GetTeam() == -1)
if(g_Config.m_SvSpectatorVotes == 0 && p->GetTeam() == TEAM_SPECTATORS)
{
SendChatTarget(ClientId, "Spectators aren't allowed to start a vote.");
return;
@ -997,7 +997,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
SendChatTarget(ClientId,"Use /pause first then you can kill");
else{
p->m_Last_SetTeam = Server()->Tick();
if(p->GetTeam() == -1 || pMsg->m_Team == -1)
if(p->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS)
m_VoteUpdate = true;
p->SetTeam(pMsg->m_Team);
}

View file

@ -34,8 +34,8 @@ IGameController::IGameController(class CGameContext *pGameServer)
m_RoundStartTick = Server()->Tick();
m_RoundCount = 0;
m_GameFlags = 0;
//m_aTeamscore[0] = 0;
//m_aTeamscore[1] = 0;
//m_aTeamscore[TEAM_RED] = 0;
//m_aTeamscore[TEAM_BLUE] = 0;
m_aMapWish[0] = 0;
m_UnbalancedTick = -1;
@ -96,7 +96,7 @@ bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
CSpawnEval Eval;
// spectators can't spawn
if(pPlayer->GetTeam() == -1)
if(pPlayer->GetTeam() == TEAM_SPECTATORS)
return false;
/*if(IsTeamplay())
@ -378,8 +378,16 @@ void IGameController::ResetGame()
const char *IGameController::GetTeamName(int Team)
{
if(Team == 0)
return "game";
/*
if(Team == TEAM_RED)
return "red team";
else if(Team == TEAM_BLUE)
return "blue team";
}
else
{*/
if(Team == 0)
return "game";
return "spectators";
}
@ -394,6 +402,8 @@ void IGameController::StartRound()
m_SuddenDeath = 0;
m_GameOverTick = -1;
GameServer()->m_World.m_Paused = false;
//m_aTeamscore[TEAM_RED] = 0;
//m_aTeamscore[TEAM_BLUE] = 0;
m_ForceBalanced = false;
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS);
@ -498,7 +508,7 @@ void IGameController::OnPlayerInfoChange(class CPlayer *pP)
const int aTeamColors[2] = {65387, 10223467};
if(IsTeamplay())
{
if(pP->GetTeam() >= 0 || pP->GetTeam() <= 1)
if(pP->GetTeam() >= TEAM_RED && pP->GetTeam() <= TEAM_BLUE)
{
pP->m_TeeInfos.m_UseCustomColor = 1;
pP->m_TeeInfos.m_ColorBody = aTeamColors[pP->GetTeam()];
@ -609,7 +619,7 @@ void IGameController::Tick()
float aPScore[MAX_CLIENTS] = {0.0f};
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != -1)
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
{
aT[GameServer()->m_apPlayers[i]->GetTeam()]++;
aPScore[i] = GameServer()->m_apPlayers[i]->m_Score*Server()->TickSpeed()*60.0f/
@ -659,7 +669,7 @@ void IGameController::Tick()
{
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != -1 && !Server()->IsAuthed(i))
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS && !Server()->IsAuthed(i))
{
if(Server()->Tick() > GameServer()->m_apPlayers[i]->m_LastActionTick+g_Config.m_SvInactiveKickTime*Server()->TickSpeed()*60)
{
@ -668,7 +678,7 @@ void IGameController::Tick()
case 0:
{
// move player to spectator
GameServer()->m_apPlayers[i]->SetTeam(-1);
GameServer()->m_apPlayers[i]->SetTeam(TEAM_SPECTATORS);
}
break;
case 1:
@ -676,12 +686,12 @@ void IGameController::Tick()
// move player to spectator if the reserved slots aren't filled yet, kick him otherwise
int Spectators = 0;
for(int j = 0; j < MAX_CLIENTS; ++j)
if(GameServer()->m_apPlayers[j] && GameServer()->m_apPlayers[j]->GetTeam() == -1)
if(GameServer()->m_apPlayers[j] && GameServer()->m_apPlayers[j]->GetTeam() == TEAM_SPECTATORS)
++Spectators;
if(Spectators >= g_Config.m_SvSpectatorSlots)
Server()->Kick(i, "Kicked for inactivity");
else
GameServer()->m_apPlayers[i]->SetTeam(-1);
GameServer()->m_apPlayers[i]->SetTeam(TEAM_SPECTATORS);
}
break;
case 2:
@ -705,8 +715,8 @@ void IGameController::Tick()
{
if(IsTeamplay())
{
Prog = max(Prog, (m_aTeamscore[0]*100)/g_Config.m_SvScorelimit);
Prog = max(Prog, (m_aTeamscore[1]*100)/g_Config.m_SvScorelimit);
Prog = max(Prog, (m_aTeamscore[TEAM_RED]*100)/g_Config.m_SvScorelimit);
Prog = max(Prog, (m_aTeamscore[TEAM_BLUE]*100)/g_Config.m_SvScorelimit);
}
else
{
@ -760,14 +770,14 @@ void IGameController::Snap(int SnappingClient)
if(SnappingClient == -1)
{
// we are recording a demo, just set the scores
pGameObj->m_TeamscoreRed = 0;//m_aTeamscore[0];
pGameObj->m_TeamscoreBlue = 0;//m_aTeamscore[1];
pGameObj->m_TeamscoreRed = 0;// m_aTeamscore[TEAM_RED];
pGameObj->m_TeamscoreBlue = 0;// m_aTeamscore[TEAM_BLUE];
}
else
{
// TODO: this little hack should be removed
pGameObj->m_TeamscoreRed = /*IsTeamplay() ? m_aTeamscore[0] : */GameServer()->m_apPlayers[SnappingClient]->m_Score;
pGameObj->m_TeamscoreBlue = 0;//m_aTeamscore[1];
pGameObj->m_TeamscoreRed = /*IsTeamplay() ? m_aTeamscore[TEAM_RED] : */GameServer()->m_apPlayers[SnappingClient]->m_Score;
pGameObj->m_TeamscoreBlue = 0;// m_aTeamscore[TEAM_BLUE];
}
}
@ -782,15 +792,15 @@ int IGameController::GetAutoTeam(int Notthisid)
{
if(GameServer()->m_apPlayers[i] && i != Notthisid)
{
if(GameServer()->m_apPlayers[i]->GetTeam() == 0 || GameServer()->m_apPlayers[i]->GetTeam() == 1)
if(GameServer()->m_apPlayers[i]->GetTeam() >= TEAM_RED && GameServer()->m_apPlayers[i]->GetTeam() <= TEAM_BLUE)
aNumplayers[GameServer()->m_apPlayers[i]->GetTeam()]++;
}
}
int Team = 0;
//if(IsTeamplay())
// Team = aNumplayers[0] > aNumplayers[1] ? 1 : 0;
//Team = aNumplayers[TEAM_RED] > aNumplayers[TEAM_BLUE] ? TEAM_BLUE : TEAM_RED;
if(CanJoinTeam(Team, Notthisid))
return Team;
return -1;
@ -798,7 +808,7 @@ int IGameController::GetAutoTeam(int Notthisid)
bool IGameController::CanJoinTeam(int Team, int Notthisid)
{
if(Team == -1 || (GameServer()->m_apPlayers[Notthisid] && GameServer()->m_apPlayers[Notthisid]->GetTeam() != -1))
if(Team == TEAM_SPECTATORS || (GameServer()->m_apPlayers[Notthisid] && GameServer()->m_apPlayers[Notthisid]->GetTeam() != TEAM_SPECTATORS))
return true;
int aNumplayers[2] = {0,0};
@ -806,7 +816,7 @@ bool IGameController::CanJoinTeam(int Team, int Notthisid)
{
if(GameServer()->m_apPlayers[i] && i != Notthisid)
{
if(GameServer()->m_apPlayers[i]->GetTeam() >= 0 || GameServer()->m_apPlayers[i]->GetTeam() == 1)
if(GameServer()->m_apPlayers[i]->GetTeam() >= TEAM_RED && GameServer()->m_apPlayers[i]->GetTeam() <= TEAM_BLUE)
aNumplayers[GameServer()->m_apPlayers[i]->GetTeam()]++;
}
}
@ -823,7 +833,7 @@ bool IGameController::CheckTeamBalance()
for(int i = 0; i < MAX_CLIENTS; i++)
{
CPlayer *pP = GameServer()->m_apPlayers[i];
if(pP && pP->GetTeam() != -1)
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
aT[pP->GetTeam()]++;
}
@ -849,26 +859,26 @@ bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam)
{
int aT[2] = {0, 0};
if (!IsTeamplay() || JoinTeam == -1 || !g_Config.m_SvTeambalanceTime)
if (!IsTeamplay() || JoinTeam == TEAM_SPECTATORS || !g_Config.m_SvTeambalanceTime)
return true;
for(int i = 0; i < MAX_CLIENTS; i++)
{
CPlayer *pP = GameServer()->m_apPlayers[i];
if(pP && pP->GetTeam() != -1)
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
aT[pP->GetTeam()]++;
}
// simulate what would happen if changed team
aT[JoinTeam]++;
if (pPlayer->GetTeam() != -1)
if (pPlayer->GetTeam() != TEAM_SPECTATORS)
aT[JoinTeam^1]--;
// there is a player-difference of at least 2
if(absolute(aT[0]-aT[1]) >= 2)
{
// player wants to join team with less players
if ((aT[0] < aT[1] && JoinTeam == 0) || (aT[0] > aT[1] && JoinTeam == 1))
if ((aT[0] < aT[1] && JoinTeam == TEAM_RED) || (aT[0] > aT[1] && JoinTeam == TEAM_BLUE))
return true;
else
return false;
@ -915,10 +925,10 @@ void IGameController::DoTeamScoreWincheck()
if(m_GameOverTick == -1 && !m_Warmup)
{
// check score win condition
if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[0] >= g_Config.m_SvScorelimit || m_aTeamscore[1] >= g_Config.m_SvScorelimit)) ||
if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[TEAM_RED] >= g_Config.m_SvScorelimit || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvScorelimit)) ||
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
{
if(m_aTeamscore[0] != m_aTeamscore[1])
if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE])
EndRound();
else
m_SuddenDeath = 1;
@ -931,9 +941,9 @@ void IGameController::DoTeamScoreWincheck()
int IGameController::ClampTeam(int Team)
{
if(Team < 0) // spectator
return -1;
if(Team < 0)
return TEAM_SPECTATORS;
//if(IsTeamplay())
// return Team&1;
return 0;
return 0;
}

View file

@ -23,8 +23,8 @@ bool CGameControllerCTF::OnEntity(int Index, vec2 Pos)
return true;
int Team = -1;
if(Index == ENTITY_FLAGSTAND_RED) Team = 0;
if(Index == ENTITY_FLAGSTAND_BLUE) Team = 1;
if(Index == ENTITY_FLAGSTAND_RED) Team = TEAM_RED;
if(Index == ENTITY_FLAGSTAND_BLUE) Team = TEAM_BLUE;
if(Team == -1 || m_apFlags[Team])
return false;
@ -143,7 +143,7 @@ void CGameControllerCTF::Tick()
int Num = GameServer()->m_World.FindEntities(F->m_Pos, CFlag::ms_PhysSize, (CEntity**)apCloseCCharacters, MAX_CLIENTS, NETOBJTYPE_CHARACTER);
for(int i = 0; i < Num; i++)
{
if(!apCloseCCharacters[i]->IsAlive() || apCloseCCharacters[i]->GetPlayer()->GetTeam() == -1 || GameServer()->Collision()->IntersectLine(F->m_Pos, apCloseCCharacters[i]->m_Pos, NULL, NULL))
if(!apCloseCCharacters[i]->IsAlive() || apCloseCCharacters[i]->GetPlayer()->GetTeam() == TEAM_SPECTATORS || GameServer()->Collision()->IntersectLine(F->m_Pos, apCloseCCharacters[i]->m_Pos, NULL, NULL))
continue;
if(apCloseCCharacters[i]->GetPlayer()->GetTeam() == F->m_Number)

View file

@ -159,10 +159,10 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
if(Character)
Character->OnDirectInput(NewInput);
if(!Character && m_Team >= 0 && (NewInput->m_Fire&1))
if(!Character && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1))
m_Spawning = true;
if(!Character && m_Team == -1)
if(!Character && m_Team == TEAM_SPECTATORS)
m_ViewPos = vec2(NewInput->m_TargetX, NewInput->m_TargetY);
// check for activity
@ -195,7 +195,7 @@ void CPlayer::KillCharacter(int Weapon)
void CPlayer::Respawn()
{
if(m_Team > -1)
if(m_Team != TEAM_SPECTATORS)
m_Spawning = true;
}

View file

@ -9,6 +9,7 @@
MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements", -1)
MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show nameplates", -1)
MACRO_CONFIG_INT(ClNameplatesAlways, cl_nameplates_always, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show nameplats disregarding of distance", -1)
MACRO_CONFIG_INT(ClNameplatesSize, cl_nameplates_size, 50, 0, 100, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Size of the nameplates from 0 to 100%", -1)
MACRO_CONFIG_INT(ClAutoswitchWeapons, cl_autoswitch_weapons, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Auto switch weapon on pickup", -1)
MACRO_CONFIG_INT(ClShowfps, cl_showfps, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ingame FPS counter", -1)