Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #26

Merged
merged 20 commits into from
Apr 26, 2019
Merged

Dev #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ file(STRINGS src/game/version.h VERSION_LINE
REGEX GAME_RELEASE_VERSION
)

if(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"")
if(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\\.([0-9]+|[0-9]+\\.[0-9]+)\"")
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
set(VERSION_PATCH ${CMAKE_MATCH_3})
Expand Down Expand Up @@ -389,7 +389,10 @@ elseif(TARGET_OS STREQUAL "mac")
set(PLATFORM_LIBS ${CARBON})
else()
set(PLATFORM_CLIENT)
set(PLATFORM_CLIENT_LIBS GL GLU X11)
find_package(OpenGL)
find_package(X11)
set(PLATFORM_CLIENT_LIBS ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${X11_X11_LIB})
set(PLATFORM_CLIENT_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR} ${X11_X11_INCLUDE_PATH})
if(TARGET_OS STREQUAL "linux")
set(PLATFORM_LIBS rt) # clock_gettime for glibc < 2.17
else()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![CircleCI](https://circleci.com/gh/AssassinTee/catch64.svg?style=shield)](https://circleci.com/gh/AssassinTee/catch64)
[![Build status](https://ci.appveyor.com/api/projects/status/uai64nkyvc8tgc36/branch/master?svg=true)](hhttps://ci.appveyor.com/project/AssassinTee/catch64)
[![release version](https://img.shields.io/github/release/AssassinTee/catch64.svg?style=flat)](https://github.com/AssassinTee/catch64/releases)
![Teeworlds version](https://img.shields.io/badge/Teeworlds-0.7.3-brightgreen.svg)
![Teeworlds version](https://img.shields.io/badge/Teeworlds-0.7.3.1-brightgreen.svg)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/AssassinTee/catch64/issues)
[![HitCount](http://hits.dwyl.io/AssassinTee/catch64.svg)](http://hits.dwyl.io/AssassinTee/catch64)
> _"HITS - How Idiots Track Success"_
Expand Down
10 changes: 9 additions & 1 deletion src/engine/shared/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
IOHANDLE MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_READ, IStorage::TYPE_ALL);
if(!MapFile)
{
// try the downloaded maps
// try the downloaded maps (sha256)
char aSha256[SHA256_MAXSTRSIZE];
sha256_str(Sha256, aSha256, sizeof(aSha256));
str_format(aMapFilename, sizeof(aMapFilename), "downloadedmaps/%s_%s.map", pMap, aSha256);
MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_READ, IStorage::TYPE_ALL);
}
if(!MapFile)
{
// try the downloaded maps (crc)
str_format(aMapFilename, sizeof(aMapFilename), "downloadedmaps/%s_%08x.map", pMap, Crc);
MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_READ, IStorage::TYPE_ALL);
}
Expand Down
8 changes: 6 additions & 2 deletions src/game/client/components/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ void CChat::OnRender()
int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES;
CLine& Line = m_aLines[r];

if(m_aLines[r].m_aText[0] == 0) break;
if(Line.m_aText[0] == 0)
break;

if(Line.m_ClientID >= 0 && m_pClient->m_aClients[Line.m_ClientID].m_ChatIgnore)
break;

if(Now > Line.m_Time+16*TimeFreq && !m_Show)
break;
Expand Down Expand Up @@ -1163,7 +1167,7 @@ int CChat::IdentifyNameParameter(const char* pCommand) const
if(TargetID != -1)
{
// duplicate; be conservative
dbg_msg("chat", "name duplicate found, aborting whisper command");
dbg_msg("chat", "name duplicate found, aborting command");
return -1;
}
TargetID = i;
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void CGameConsole::OnRender()
TextRender()->Text(0, 10.0f, 0.0f, FontSize, aBuf, -1);

// render version
str_format(aBuf, sizeof(aBuf), "v%s", GAME_VERSION);
str_format(aBuf, sizeof(aBuf), "v%s", GAME_RELEASE_VERSION);
float Width = TextRender()->TextWidth(0, FontSize, aBuf, -1);
TextRender()->Text(0, Screen.w-Width-10.0f, 0.0f, FontSize, aBuf, -1);
}
Expand Down
7 changes: 2 additions & 5 deletions src/game/client/components/maplayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void CMapLayers::OnInit()

static void PlaceEggDoodads(int LayerWidth, int LayerHeight, CTile* aOutTiles, CTile* aGameLayerTiles, int ItemWidth, int ItemHeight, const int* aImageTileID, int ImageTileIDCount, int Freq)
{
for(int y = 0; y < LayerHeight; y++)
for(int y = 0; y < LayerHeight-ItemHeight; y++)
{
for(int x = 0; x < LayerWidth; x++)
for(int x = 0; x < LayerWidth-ItemWidth; x++)
{
bool Overlap = false;
bool ObstructedByWall = false;
Expand All @@ -99,9 +99,6 @@ static void PlaceEggDoodads(int LayerWidth, int LayerHeight, CTile* aOutTiles, C
{
for(int ix = 0; ix < ItemWidth; ix++)
{
if(y+iy >= LayerHeight || x+ix >= LayerWidth)
continue;

int Tid = (y+iy) * LayerWidth + (x+ix);
int DownTid = (y+iy+1) * LayerWidth + (x+ix);

Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/menus_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
UI()->DoLabel(&Version, aBuf, 14.0f, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
UI()->DoLabel(&Version, GAME_VERSION, 14.0f, CUI::ALIGN_RIGHT);
UI()->DoLabel(&Version, GAME_RELEASE_VERSION, 14.0f, CUI::ALIGN_RIGHT);

if(NewPage != -1)
SetMenuPage(NewPage);
Expand Down
31 changes: 19 additions & 12 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,6 @@ void CCharacter::Die(int Killer, int Weapon)
m_Alive = false;
m_pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
}
if(GameServer()->m_apPlayers[Killer]->GetTeamID() == GameServer()->m_apPlayers[m_pPlayer->GetCID()]->GetTeamID() && Killer != m_pPlayer->GetCID())
return;
int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon);

char aBuf[256];
Expand Down Expand Up @@ -694,8 +692,14 @@ void CCharacter::Die(int Killer, int Weapon)

bool CCharacter::TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weapon)
{
//This is for rocket jumps
m_Core.m_Vel += Force;

//If player is another player but in same team
if(GameServer()->m_apPlayers[From] && GameServer()->m_apPlayers[From]->GetTeamID() == m_pPlayer->GetTeamID() && From != m_pPlayer->GetCID())
{
return false;
}
Die(From, Weapon);
if (From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From])
{
Expand All @@ -705,20 +709,23 @@ bool CCharacter::TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weap
pChr->m_EmoteType = EMOTE_HAPPY;
pChr->m_EmoteStop = Server()->Tick() + Server()->TickSpeed();
}

int64 Mask = CmaskOne(From);
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(GameServer()->m_apPlayers[i] && (GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS || GameServer()->m_apPlayers[i]->m_DeadSpecMode) &&
GameServer()->m_apPlayers[i]->GetSpectatorID() == From)
Mask |= CmaskOne(i);
}

//There you have sound TeeSlayer and Dune :O
GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask);
}

//This happens with selfdamage, too
m_EmoteType = EMOTE_PAIN;
m_EmoteStop = Server()->Tick() + 500 * Server()->TickSpeed() / 1000;

int64 Mask = CmaskOne(From);
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(GameServer()->m_apPlayers[i] && (GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS || GameServer()->m_apPlayers[i]->m_DeadSpecMode) &&
GameServer()->m_apPlayers[i]->GetSpectatorID() == From)
Mask |= CmaskOne(i);
}

//There you have sound TeeSlayer and Dune :O
GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask);
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT);

return true;
Expand Down
9 changes: 9 additions & 0 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,12 @@ void CGameContext::SetStartTeam(int ClientID)

void CGameContext::OnClientConnected(int ClientID, bool Dummy, bool AsSpec)
{
if(m_apPlayers[ClientID])
{
dbg_assert(m_apPlayers[ClientID]->IsDummy(), "invalid clientID");
OnClientDrop(ClientID, "removing dummy");
}

m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, Dummy, AsSpec);

if(Dummy)
Expand Down Expand Up @@ -1811,6 +1817,9 @@ void CGameContext::OnInit()
g_Config.m_SvPlayerSlots = Server()->MaxClients();

#ifdef CONF_DEBUG
// clamp dbg_dummies to 0..MaxClients-1
if(Server()->MaxClients() <= g_Config.m_DbgDummies)
g_Config.m_DbgDummies = Server()->MaxClients();
if(g_Config.m_DbgDummies)
{
for(int i = 0; i < g_Config.m_DbgDummies ; i++)
Expand Down
11 changes: 8 additions & 3 deletions src/game/server/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ IGameController::IGameController(CGameContext *pGameServer)
m_aNumSpawnPoints[0] = 0;
m_aNumSpawnPoints[1] = 0;
m_aNumSpawnPoints[2] = 0;

m_TopTeam = -1;
}

//activity
Expand Down Expand Up @@ -435,6 +437,7 @@ bool IGameController::DoWincheckMatch()
int Topscore = 0;
int TopscoreCount = 0;
int TopTeam = -1;
int TopTeamCount = 0;
bool AllInOneTeam=true;
for(int i = 0; i < MAX_CLIENTS; i++)
{
Expand All @@ -455,16 +458,18 @@ bool IGameController::DoWincheckMatch()
TopTeam = GameServer()->m_apPlayers[i]->GetTeamID();
else if(TopTeam != GameServer()->m_apPlayers[i]->GetTeamID())
AllInOneTeam = false;
TopTeamCount++;
}
}
}

// check score win condition
if((m_GameInfo.m_ScoreLimit > 0 && Topscore >= m_GameInfo.m_ScoreLimit) ||
(m_GameInfo.m_TimeLimit > 0 && (Server()->Tick()-m_GameStartTick) >= m_GameInfo.m_TimeLimit*Server()->TickSpeed()*60) ||
(AllInOneTeam))
(AllInOneTeam && TopTeamCount > 1))
{
m_TopTeam = TopTeam;
if(m_GameState == IGS_GAME_RUNNING)
m_TopTeam = TopTeam;
if(TopscoreCount == 1 || AllInOneTeam)
{
EndMatch();
Expand Down Expand Up @@ -642,7 +647,7 @@ void IGameController::SetGameState(EGameState GameState, int Timer)
m_GameStateTimer = Timer*Server()->TickSpeed();
m_SuddenDeath = 0;
GameServer()->m_World.m_Paused = true;
if(GameServer()->m_apPlayers[m_TopTeam]) {
if(m_TopTeam >= 0 && m_TopTeam < MAX_PLAYERS && GameServer()->m_apPlayers[m_TopTeam]) {
char aBuf[256];
GameServer()->m_apPlayers[m_TopTeam]->m_Score+=g_Config.m_SvWinBonus;
char colorbuf[5];
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, bool Dummy, bool AsSpe
m_RespawnDisabled = GameServer()->m_pController->GetStartRespawnState();
m_DeadSpecMode = false;
m_Spawning = 0;
m_TeamID = 0;
m_TeamID = -1;//Value will be changed in later stage
}

CPlayer::~CPlayer()
Expand Down
2 changes: 1 addition & 1 deletion src/game/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ MACRO_CONFIG_INT(SvWinBonus, sv_win_bonus, 5, 0, 9999, CFGFLAG_SAVE|CFGFLAG_SERV

// debug
#ifdef CONF_DEBUG // this one can crash the server if not used correctly
MACRO_CONFIG_INT(DbgDummies, dbg_dummies, 0, 0, MAX_CLIENTS-1, CFGFLAG_SERVER, "")
MACRO_CONFIG_INT(DbgDummies, dbg_dummies, 0, 0, MAX_CLIENTS, CFGFLAG_SERVER, "")
#endif

MACRO_CONFIG_INT(DbgFocus, dbg_focus, 0, 0, 1, CFGFLAG_CLIENT, "")
Expand Down
4 changes: 2 additions & 2 deletions src/game/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#define GAME_VERSION "0.7.3"
#define GAME_NETVERSION "0.7 802f1be60a05665f"
#define CLIENT_VERSION 0x0703
static const char GAME_RELEASE_VERSION[8] = "0.7.3";
#define CATCH_VERSION "1.0.3"
static const char GAME_RELEASE_VERSION[8] = "0.7.3.1";
#define CATCH_VERSION "1.0.5"
#endif