Skip to content

Commit

Permalink
Merge branch 'master' into enhancements/callFetchRemote
Browse files Browse the repository at this point in the history
  • Loading branch information
xLuxy committed Jan 13, 2019
2 parents ca89123 + 27c654a commit a6b6bfb
Show file tree
Hide file tree
Showing 25 changed files with 600 additions and 444 deletions.
5 changes: 3 additions & 2 deletions Client/core/CChat.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class CChat
public:
CChat(void){};
CChat(CGUI* pManager, const CVector2D& vecPosition);
~CChat(void);
virtual ~CChat();

virtual void Draw(bool bUseCacheTexture, bool bAllowOutline);
virtual void Output(const char* szText, bool bColorCoded = true);
Expand Down Expand Up @@ -198,8 +198,9 @@ class CChat
void LoadCVars(void);

protected:
virtual void UpdatePosition(void);

void UpdateGUI(void);
void UpdatePosition(void);
void UpdateSmoothScroll(float* pfPixelScroll, int* piLineScroll);
void DrawDrawList(const SDrawList& drawList, const CVector2D& topLeftOffset = CVector2D(0, 0));
void GetDrawList(SDrawList& outDrawList, bool bUsingOutline);
Expand Down
2 changes: 1 addition & 1 deletion Client/core/CDebugView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class CDebugView : public CChat

protected:
// Debug view doesn't support position changes unlike chat box
void UpdatePosition(void){};
void UpdatePosition() override {};
};
6 changes: 6 additions & 0 deletions Client/core/Graphics/CGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,12 @@ void CGraphics::DrawMaterialPrimitiveQueued(std::vector<PrimitiveMaterialVertice
vert.fY = m_pAspectRatioConverter->ConvertPositionForAspectRatio(vert.fY);
}

if (CShaderItem* pShaderItem = DynamicCast<CShaderItem>(pMaterial))
{
// If material is a shader, use its current instance
pMaterial = pShaderItem->m_pShaderInstance;
}

// Set up a queue item
sDrawQueueItem Item;
Item.eType = QUEUE_PRIMITIVEMATERIAL;
Expand Down
32 changes: 7 additions & 25 deletions Client/game_sa/CAudioEngineSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,41 +149,23 @@ VOID CAudioEngineSA::StartRadio(unsigned int station)
// 43 = race one
// 32 = help
// 13 = camera take picture
VOID CAudioEngineSA::PlayFrontEndSound(DWORD dwSound)
VOID CAudioEngineSA::PlayFrontEndSound(DWORD dwEventID)
{
if (*(DWORD*)VAR_AudioEventVolumes != 0 && dwSound <= 101) // may prevent a crash
if (*(DWORD*)VAR_AudioEventVolumes != 0 && dwEventID <= 101) // may prevent a crash
{
DEBUG_TRACE("VOID CAudioEngineSA::PlayFrontEndSound(DWORD dwSound)");
DWORD dwFunc = FUNC_ReportFrontendAudioEvent;
FLOAT fUnknown = 1.0f;
FLOAT fSpeed = 1.0f;
FLOAT fVolumeChange = 0.0f;
_asm
{
push fUnknown
push 0
push dwSound
push fSpeed
push fVolumeChange
push dwEventID
mov ecx, CLASS_CAudioEngine
call dwFunc
}
}

/* DWORD dwAudioEntity = 0xB6BC90;
DWORD dwFunc = 0x507290;
_asm
{
push 1
push dwSound
call dwFunc
}
dwFunc = 0x5072B0;
_asm
{
push dwSound
mov ecx,dwAudioEntity
call dwFunc
}*/
}

VOID CAudioEngineSA::SetEffectsMasterVolume(BYTE bVolume)
Expand Down
39 changes: 39 additions & 0 deletions Client/mods/deathmatch/logic/CRegisteredCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,45 @@ void CRegisteredCommands::CallCommandHandler(CLuaMain* pLuaMain, const CLuaFunct
Arguments.Call(pLuaMain, iLuaFunction);
}

void CRegisteredCommands::GetCommands(lua_State* luaVM)
{
unsigned int uiIndex = 0;

lua_newtable(luaVM);

for (SCommand* pCommand : m_Commands)
{
// Create an entry table: {'command', resource}
lua_pushinteger(luaVM, ++uiIndex);
lua_createtable(luaVM, 0, 2);
{
lua_pushstring(luaVM, pCommand->strKey.c_str());
lua_rawseti(luaVM, -2, 1);

lua_pushresource(luaVM, pCommand->pLuaMain->GetResource());
lua_rawseti(luaVM, -2, 2);
}
lua_settable(luaVM, -3);
}
}

void CRegisteredCommands::GetCommands(lua_State* luaVM, CLuaMain* pTargetLuaMain)
{
unsigned int uiIndex = 0;

lua_newtable(luaVM);

for (SCommand* pCommand : m_Commands)
{
if (pCommand->pLuaMain == pTargetLuaMain)
{
lua_pushinteger(luaVM, ++uiIndex);
lua_pushstring(luaVM, pCommand->strKey.c_str());
lua_settable(luaVM, -3);
}
}
}

void CRegisteredCommands::TakeOutTheTrash(void)
{
list<SCommand*>::iterator iter = m_TrashCan.begin();
Expand Down
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/CRegisteredCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class CRegisteredCommands

bool CommandExists(const char* szKey, class CLuaMain* pLuaMain = NULL);

void GetCommands(lua_State* luaVM);
void GetCommands(lua_State* luaVM, CLuaMain* pTargetLuaMain);

bool ProcessCommand(const char* szKey, const char* szArguments);

private:
Expand Down
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ void CResourceManager::StopAll(void)
bool CResourceManager::ParseResourcePathInput(std::string strInput, CResource*& pResource, std::string* pStrPath, std::string* pStrMetaPath)
{
ReplaceOccurrencesInString(strInput, "\\", "/");

// Disallow file paths with a directory separator at the end
if (strInput.back() == '/')
return false;

eAccessType accessType = ACCESS_PUBLIC;
std::string strMetaPath;

Expand Down
34 changes: 34 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,37 @@ int CLuaFunctionDefs::ExecuteCommandHandler(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

int CLuaFunctionDefs::GetCommandHandlers(lua_State* luaVM)
{
// table getCommandHandlers ( [ resource sourceResource ] );
CResource* pResource = nullptr;

CScriptArgReader argStream(luaVM);

if (!argStream.NextIsNil() && !argStream.NextIsNone())
argStream.ReadUserData(pResource);

if (argStream.HasErrors())
{
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushnil(luaVM);
return 1;
}

if (pResource)
{
CLuaMain* pLuaMain = pResource->GetVM();

if (pLuaMain)
m_pRegisteredCommands->GetCommands(luaVM, pLuaMain);
else
lua_newtable(luaVM);
}
else
{
m_pRegisteredCommands->GetCommands(luaVM);
}

return 1;
}
39 changes: 34 additions & 5 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,46 @@ int CLuaFunctionDefs::TriggerServerEvent(lua_State* luaVM)

if (!argStream.HasErrors())
{
// Trigger it
if (CStaticFunctionDefinitions::TriggerServerEvent(strName, *pCallWithEntity, Arguments))
if (!pCallWithEntity->IsLocalEntity())
{
lua_pushboolean(luaVM, true);
if (CStaticFunctionDefinitions::TriggerServerEvent(strName, *pCallWithEntity, Arguments))
{
lua_pushboolean(luaVM, true);
}
else
{
lua_pushboolean(luaVM, false);

// Show a warning for clientside elements in the argument chain
for (uint i = 0; i < Arguments.Count(); ++i)
{
CLuaArgument* pArgument = Arguments[i];

if (!pArgument)
continue;

if (pArgument->GetType() != LUA_TLIGHTUSERDATA && pArgument->GetType() != LUA_TUSERDATA)
continue;

CClientEntity* pEntity = pArgument->GetElement();

if (!pEntity || !pEntity->IsLocalEntity())
continue;

// Extra arguments begin at argument 3
m_pScriptDebugging->LogError(luaVM, "clientside element '%s' at argument %u @ 'triggerServerEvent'", pEntity->GetTypeName().c_str(), i + 3);
}
}

return 1;
}

argStream.SetCustomError("element is clientside", "Bad source element");
}
else

if (argStream.HasErrors())
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

// Failed
lua_pushboolean(luaVM, false);
return 1;
}
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class CLuaFunctionDefs
LUA_DECLARE(AddCommandHandler);
LUA_DECLARE(RemoveCommandHandler);
LUA_DECLARE(ExecuteCommandHandler);
LUA_DECLARE(GetCommandHandlers);

// Utility
LUA_DECLARE(GetNetworkUsageData);
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/lua/CLuaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ void CLuaManager::LoadCFunctions(void)
{"addCommandHandler", CLuaFunctionDefs::AddCommandHandler},
{"removeCommandHandler", CLuaFunctionDefs::RemoveCommandHandler},
{"executeCommandHandler", CLuaFunctionDefs::ExecuteCommandHandler},
{"getCommandHandlers", CLuaFunctionDefs::GetCommandHandlers},

// Utility
{"getNetworkUsageData", CLuaFunctionDefs::GetNetworkUsageData},
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/StdInc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <sstream>
#include <mutex>
#include <unordered_set>
#include <future>

// Forward declarations
class CAclRightName;
Expand Down
38 changes: 31 additions & 7 deletions Server/mods/deathmatch/logic/CAccountManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,22 +387,46 @@ bool CAccountManager::IntegrityCheck()
return true;
}

CAccount* CAccountManager::Get(const char* szName)
CAccount* CAccountManager::Get(const char* szName, const char* szPassword, bool bCaseSensitive)
{
if (szName && szName[0])
{
std::vector<CAccount*> results;
m_List.FindAccountMatches(&results, szName, true);
for (uint i = 0; i < results.size(); i++)
m_List.FindAccountMatches(&results, szName, bCaseSensitive);

if (!bCaseSensitive)
{
CAccount* pAccount = results[i];
if (pAccount->IsRegistered())
CAccount* pFirstMatchAccount = nullptr;

for (CAccount* pAccount : results)
{
return pAccount;
if (!pAccount->IsRegistered())
continue;

if (szPassword && !pAccount->IsPassword(szPassword))
continue;

if (pAccount->GetName() == szName)
{
return pAccount;
}
else if (!pFirstMatchAccount)
{
pFirstMatchAccount = pAccount;
}
}

return pFirstMatchAccount;
}

for (CAccount* pAccount : results)
{
if (pAccount->IsRegistered())
return pAccount;
}
}
return NULL;

return nullptr;
}

CAccount* CAccountManager::GetAccountFromScriptID(uint uiScriptID)
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CAccountManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class CAccountManager
bool SaveSettings(void);
bool IntegrityCheck(void);

CAccount* Get(const char* szName);
CAccount* Get(const char* szName, const char* szPassword = nullptr, bool caseSensitive = true);
CAccount* GetAccountFromScriptID(uint uiScriptID);
SString GetActiveCaseVariation(const SString& strName);

Expand Down
Loading

0 comments on commit a6b6bfb

Please sign in to comment.