forked from Mirrors/openclonk
Strip c4group of unnecessary code dependencies
Fixes issue #21 (c4group build failure)
parent
7a38556516
commit
2a38d0056d
|
@ -602,6 +602,7 @@ target_link_libraries(clonk
|
|||
)
|
||||
target_link_libraries(c4group
|
||||
${ZLIB_LIBRARIES}
|
||||
${WS2}
|
||||
${OPENSSL}
|
||||
)
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ class C4Application: public CStdApp
|
|||
bool OpenGame();
|
||||
bool PreInit();
|
||||
static BOOL ProcessCallback(const char *szMessage, int iProcess);
|
||||
void ApplyResolutionConstraints();
|
||||
|
||||
virtual void OnCommand(const char *szCmd);
|
||||
|
||||
|
|
|
@ -141,8 +141,9 @@ class C4ConfigGraphics
|
|||
int32_t RenderInactiveEM; // draw vieports even if inactive in CPEM
|
||||
int32_t DisableGamma;
|
||||
int32_t Monitor; // monitor index to play on
|
||||
int32_t FireParticles; // draw extended fire particles if enabled (defualt on)
|
||||
int32_t FireParticles; // draw extended fire particles if enabled (default on)
|
||||
int32_t MaxRefreshDelay; // minimum time after which graphics should be refreshed (ms)
|
||||
int32_t EnableShaders; // enable pixel shaders on engines that support them
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
void ApplyResolutionConstraints();
|
||||
};
|
||||
|
|
|
@ -486,7 +486,7 @@ void C4ConfigShareware::ClearRegistrationError()
|
|||
RegistrationError.Clear();
|
||||
}
|
||||
|
||||
bool C4ConfigShareware::IsConfidentialData(const char *szInput, bool fShowWarningMessage)
|
||||
bool C4ConfigShareware::IsConfidentialData(const char *szInput)
|
||||
{
|
||||
// safety
|
||||
if (!szInput) return false;
|
||||
|
@ -496,10 +496,12 @@ bool C4ConfigShareware::IsConfidentialData(const char *szInput, bool fShowWarnin
|
|||
const char *szWebCode = GetRegistrationData("WebCode");
|
||||
if (szWebCode && *szWebCode) if (SSearchNoCase(szInput, szWebCode))
|
||||
{
|
||||
if (fShowWarningMessage && ::pGUI)
|
||||
::pGUI->ShowErrorMessage(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));
|
||||
/* if (fShowWarningMessage && ::pGUI)
|
||||
::pGUI->ShowErrorMessage(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));*/
|
||||
return true;
|
||||
}
|
||||
// all OK
|
||||
return false;
|
||||
}
|
||||
|
||||
C4ConfigShareware Config;
|
||||
|
|
|
@ -54,7 +54,7 @@ class C4ConfigShareware: public C4Config
|
|||
const char* GetKeyPath();
|
||||
StdStrBuf GetKeyMD5();
|
||||
// checks for phising attacks: Return true if input contains user's webcode
|
||||
bool IsConfidentialData(const char *szInput, bool fShowWarningMessage);
|
||||
bool IsConfidentialData(const char *szInput);
|
||||
protected:
|
||||
StdStrBuf RegistrationError;
|
||||
bool HandleError(const char *strMessage);
|
||||
|
|
|
@ -157,6 +157,27 @@ bool C4Application::DoInit()
|
|||
return true;
|
||||
#endif
|
||||
|
||||
DDrawCfg.Shader = Config.Graphics.EnableShaders;
|
||||
switch (Config.Graphics.Engine) {
|
||||
#ifdef USE_DIRECTX
|
||||
case GFXENGN_DIRECTX:
|
||||
case GFXENGN_DIRECTXS:
|
||||
// Direct3D
|
||||
DDrawCfg.Set(Config.Graphics.NewGfxCfg, (float) Config.Graphics.BlitOff/100.0f);
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
case GFXENGN_OPENGL:
|
||||
// OpenGL
|
||||
DDrawCfg.Set(Config.Graphics.NewGfxCfgGL, (float) Config.Graphics.BlitOffGL/100.0f);
|
||||
break;
|
||||
#endif
|
||||
default: ; // Always have at least one statement
|
||||
}
|
||||
|
||||
// Fixup resolution
|
||||
ApplyResolutionConstraints();
|
||||
|
||||
// activate
|
||||
Active=TRUE;
|
||||
|
||||
|
@ -219,6 +240,38 @@ bool C4Application::DoInit()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void C4Application::ApplyResolutionConstraints()
|
||||
{
|
||||
// Enumerate display modes
|
||||
int32_t idx = 0, iXRes, iYRes, iBitDepth;
|
||||
int32_t best_match = -1;
|
||||
uint32_t best_delta = ~0;
|
||||
int32_t ResX = Config.Graphics.ResX, ResY = Config.Graphics.ResY, BitDepth = Config.Graphics.BitDepth;
|
||||
while (GetIndexedDisplayMode(idx++, &iXRes, &iYRes, &iBitDepth, Config.Graphics.Monitor))
|
||||
{
|
||||
uint32_t delta = std::abs(ResX*ResY - iXRes*iYRes);
|
||||
if (!delta && iBitDepth == BitDepth)
|
||||
return; // Exactly the expected mode
|
||||
if (delta < best_delta)
|
||||
{
|
||||
// Better match than before
|
||||
best_match = idx;
|
||||
best_delta = delta;
|
||||
}
|
||||
}
|
||||
if (best_match != -1)
|
||||
{
|
||||
// Apply next-best mode
|
||||
GetIndexedDisplayMode(best_match, &iXRes, &iYRes, &iBitDepth, Config.Graphics.Monitor);
|
||||
if (iXRes != ResX || iYRes != ResY)
|
||||
// Don't warn if only bit depth changes
|
||||
// Also, lang table not loaded yet
|
||||
LogF("Warning: The selected resolution %dx%d is not available and has been changed to %dx%d.", ResX, ResY, iXRes, iYRes);
|
||||
ResX = iXRes; ResY = iYRes;
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Application::PreInit()
|
||||
{
|
||||
if (!Game.PreInit()) return false;
|
||||
|
|
|
@ -836,7 +836,11 @@ bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
|
|||
// safety
|
||||
if (!szInput || !*szInput || !pChatSheet) return fResult;
|
||||
// check confidential data
|
||||
if (Config.IsConfidentialData(szInput, true)) return fResult;
|
||||
if (Config.IsConfidentialData(szInput))
|
||||
{
|
||||
pChatSheet->DoError(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));
|
||||
return fResult;
|
||||
}
|
||||
// command?
|
||||
if (*szInput == '/' && !SEqual2NoCase(szInput + 1, "me "))
|
||||
{
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#ifndef BIG_C4INCLUDE
|
||||
#include <C4Log.h>
|
||||
#include <C4Components.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4Network2.h>
|
||||
#include <C4Language.h>
|
||||
#endif
|
||||
|
@ -162,7 +161,7 @@ void C4ConfigGraphics::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(Monitor, "Monitor", 0 )); // 0 = D3DADAPTER_DEFAULT
|
||||
pComp->Value(mkNamingAdapt(FireParticles, "FireParticles", TRUE ));
|
||||
pComp->Value(mkNamingAdapt(MaxRefreshDelay, "MaxRefreshDelay", 30 ));
|
||||
pComp->Value(mkNamingAdapt(DDrawCfg.Shader, "Shader", 0 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(EnableShaders, "Shader", 0 ,false, true));
|
||||
}
|
||||
|
||||
void C4ConfigSound::CompileFunc(StdCompiler *pComp)
|
||||
|
@ -481,33 +480,25 @@ BOOL C4Config::Load(BOOL forceWorkingDirectory, const char *szConfigFile)
|
|||
// Config postinit
|
||||
General.DeterminePaths(forceWorkingDirectory);
|
||||
General.AdoptOldSettings();
|
||||
#ifdef HAVE_WINSOCK
|
||||
bool fWinSock = AcquireWinSock();
|
||||
#endif
|
||||
#ifdef HAVE_WINSOCK
|
||||
// Setup WS manually, so c4group doesn't depend on C4NetIO
|
||||
WSADATA wsadata;
|
||||
bool fWinSock = !WSAStartup(WINSOCK_VERSION, &wsadata);
|
||||
#endif
|
||||
if (SEqual(Network.LocalName.getData(), "Unknown"))
|
||||
{
|
||||
char LocalName[25+1]; *LocalName = 0;
|
||||
gethostname(LocalName, 25);
|
||||
if (*LocalName) Network.LocalName.Copy(LocalName);
|
||||
}
|
||||
#ifdef HAVE_WINSOCK
|
||||
if (fWinSock) ReleaseWinSock();
|
||||
#endif
|
||||
#ifdef HAVE_WINSOCK
|
||||
if (fWinSock) WSACleanup();
|
||||
#endif
|
||||
General.DefaultLanguage();
|
||||
#if defined USE_GL && !defined USE_DIRECTX
|
||||
if (Graphics.Engine == GFXENGN_DIRECTX || Graphics.Engine == GFXENGN_DIRECTXS)
|
||||
Graphics.Engine = GFXENGN_OPENGL;
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
// set ddraw config
|
||||
if (Graphics.Engine == GFXENGN_DIRECTX || Graphics.Engine == GFXENGN_DIRECTXS)
|
||||
// Direct3D
|
||||
DDrawCfg.Set(Graphics.NewGfxCfg, (float) Graphics.BlitOff/100.0f);
|
||||
else
|
||||
#endif
|
||||
// OpenGL
|
||||
DDrawCfg.Set(Graphics.NewGfxCfgGL, (float) Graphics.BlitOffGL/100.0f);
|
||||
Graphics.ApplyResolutionConstraints();
|
||||
// Warning against invalid ports
|
||||
if (Config.Network.PortTCP>0 && Config.Network.PortTCP == Config.Network.PortRefServer)
|
||||
{
|
||||
|
@ -595,36 +586,6 @@ BOOL C4Config::Save()
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void C4ConfigGraphics::ApplyResolutionConstraints()
|
||||
{
|
||||
// Enumerate display modes
|
||||
int32_t idx = 0, iXRes, iYRes, iBitDepth;
|
||||
int32_t best_match = -1;
|
||||
uint32_t best_delta = ~0;
|
||||
while (Application.GetIndexedDisplayMode(idx++, &iXRes, &iYRes, &iBitDepth, Config.Graphics.Monitor))
|
||||
{
|
||||
uint32_t delta = std::abs(ResX*ResY - iXRes*iYRes);
|
||||
if (!delta && iBitDepth == BitDepth)
|
||||
return; // Exactly the expected mode
|
||||
if (delta < best_delta)
|
||||
{
|
||||
// Better match than before
|
||||
best_match = idx;
|
||||
best_delta = delta;
|
||||
}
|
||||
}
|
||||
if (best_match != -1)
|
||||
{
|
||||
// Apply next-best mode
|
||||
Application.GetIndexedDisplayMode(best_match, &iXRes, &iYRes, &iBitDepth, Config.Graphics.Monitor);
|
||||
if (iXRes != ResX || iYRes != ResY)
|
||||
// Don't warn if only bit depth changes
|
||||
// Also, lang table not loaded yet
|
||||
LogF("Warning: The selected resolution %dx%d is not available and has been changed to %dx%d.", ResX, ResY, iXRes, iYRes);
|
||||
ResX = iXRes; ResY = iYRes;
|
||||
}
|
||||
}
|
||||
|
||||
void C4ConfigGeneral::DeterminePaths(BOOL forceWorkingDirectory)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -449,7 +449,11 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
|
|||
::MessageInput.StoreBackBuffer(szInputText);
|
||||
bool fProcessed = false;
|
||||
// check confidential data
|
||||
if (Config.IsConfidentialData(szInputText, true)) fProcessed = true;
|
||||
if (Config.IsConfidentialData(szInputText))
|
||||
{
|
||||
::pGUI->ShowErrorMessage(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));
|
||||
fProcessed = true;
|
||||
}
|
||||
// CAUTION when implementing special commands (like /quit) here:
|
||||
// those must not be executed when text is pasted, because that could crash the GUI system
|
||||
// when there are additional lines to paste, but the edit field is destructed by the command
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <C4GameLobby.h>
|
||||
#include <C4GraphicsSystem.h>
|
||||
#include <C4PlayerList.h>
|
||||
#include <C4GameControl.h>v
|
||||
#include <C4GameControl.h>
|
||||
#endif
|
||||
#include <cctype>
|
||||
|
||||
|
@ -132,8 +132,9 @@ C4GUI::Edit::InputResult C4ChatInputDialog::OnChatInput(C4GUI::Edit *edt, bool f
|
|||
// Store to back buffer
|
||||
::MessageInput.StoreBackBuffer(szInputText);
|
||||
// check confidential data - even for object input (script triggered), webcode should not be pasted here
|
||||
if (Config.IsConfidentialData(szInputText, true))
|
||||
if (Config.IsConfidentialData(szInputText))
|
||||
{
|
||||
::pGUI->ShowErrorMessage(LoadResStr("IDS_ERR_WARNINGYOUWERETRYINGTOSEN"));
|
||||
szInputText = "";
|
||||
}
|
||||
// script queried input?
|
||||
|
|
|
@ -36,7 +36,6 @@ C4Application Application;
|
|||
C4Console Console;
|
||||
C4FullScreen FullScreen;
|
||||
C4Game Game;
|
||||
C4ConfigShareware Config;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
|
|
@ -61,22 +61,17 @@ bool Log(const char *msg) {
|
|||
printf("%s\n", msg);
|
||||
return 1;
|
||||
}
|
||||
BOOL LogF(const char *strMessage, ...) {
|
||||
va_list args;
|
||||
va_start(args, strMessage);
|
||||
// Compose formatted message
|
||||
StdStrBuf Buf;
|
||||
Buf.FormatV(strMessage, args);
|
||||
// Log
|
||||
return Log(Buf.getData());
|
||||
}
|
||||
BOOL DebugLogF(const char *strMessage ...)
|
||||
{
|
||||
va_list args; va_start(args, strMessage);
|
||||
StdStrBuf Buf;
|
||||
Buf.FormatV(strMessage, args);
|
||||
return Log(Buf.getData());
|
||||
}
|
||||
#define IMPLEMENT_LOGF(func) \
|
||||
BOOL func(const char *msg, ...) { \
|
||||
va_list args; va_start(args, msg); \
|
||||
StdStrBuf Buf; \
|
||||
Buf.FormatV(msg, args); \
|
||||
return Log(Buf.getData()); \
|
||||
}
|
||||
|
||||
IMPLEMENT_LOGF(DebugLogF)
|
||||
IMPLEMENT_LOGF(LogF)
|
||||
IMPLEMENT_LOGF(LogSilentF)
|
||||
|
||||
bool ProcessGroup(const char *FilenamePar) {
|
||||
|
||||
|
@ -402,8 +397,10 @@ int UnregisterShellExtensions() {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#ifndef WIN32
|
||||
// Always line buffer mode, even if the output is not sent to a terminal
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
#endif
|
||||
// Scan options
|
||||
int iFirstGroup = 0;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
|
|
Loading…
Reference in New Issue