mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 06:53:03 +00:00
Removes unused/not implemented hooks from AppHooks. Refs f947fa6afe.
This was SVN commit r26024.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -20,11 +20,8 @@
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* hooks to allow customization / app-specific behavior.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "lib/app_hooks.h"
|
||||
|
||||
#include "lib/sysdep/sysdep.h"
|
||||
@@ -35,11 +32,6 @@
|
||||
// default implementations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void def_override_gl_upload_caps()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static const OsPath& def_get_log_dir()
|
||||
{
|
||||
static OsPath logDir;
|
||||
@@ -54,31 +46,6 @@ static void def_bundle_logs(FILE* UNUSED(f))
|
||||
}
|
||||
|
||||
|
||||
static const wchar_t* def_translate(const wchar_t* text)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
static void def_translate_free(const wchar_t* UNUSED(text))
|
||||
{
|
||||
// no-op - translate() doesn't own the pointer.
|
||||
}
|
||||
|
||||
|
||||
static void def_log(const wchar_t* text)
|
||||
{
|
||||
#if ICC_VERSION
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:181) // "invalid printf conversion" - but wchar_t* and %ls are legit
|
||||
#endif
|
||||
printf("%ls", text); // must not use wprintf, since stdout on Unix is byte-oriented
|
||||
#if ICC_VERSION
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static ErrorReactionInternal def_display_error(const wchar_t* UNUSED(text), size_t UNUSED(flags))
|
||||
{
|
||||
return ERI_NOT_IMPLEMENTED;
|
||||
@@ -95,12 +62,8 @@ static ErrorReactionInternal def_display_error(const wchar_t* UNUSED(text), size
|
||||
// having to check whether their function pointer is valid.
|
||||
static AppHooks ah =
|
||||
{
|
||||
def_override_gl_upload_caps,
|
||||
def_get_log_dir,
|
||||
def_bundle_logs,
|
||||
def_translate,
|
||||
def_translate_free,
|
||||
def_log,
|
||||
def_display_error
|
||||
};
|
||||
|
||||
@@ -117,12 +80,8 @@ void app_hooks_update(AppHooks* new_ah)
|
||||
ENSURE(new_ah);
|
||||
|
||||
#define OVERRIDE_IF_NONZERO(HOOKNAME) if(new_ah->HOOKNAME) ah.HOOKNAME = new_ah->HOOKNAME;
|
||||
OVERRIDE_IF_NONZERO(override_gl_upload_caps)
|
||||
OVERRIDE_IF_NONZERO(get_log_dir)
|
||||
OVERRIDE_IF_NONZERO(bundle_logs)
|
||||
OVERRIDE_IF_NONZERO(translate)
|
||||
OVERRIDE_IF_NONZERO(translate_free)
|
||||
OVERRIDE_IF_NONZERO(log)
|
||||
OVERRIDE_IF_NONZERO(display_error)
|
||||
#undef OVERRIDE_IF_NONZERO
|
||||
}
|
||||
@@ -143,12 +102,6 @@ bool app_hook_was_redefined(size_t offset_in_struct)
|
||||
// (boilerplate code; hides details of how to call the app hook)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ah_override_gl_upload_caps()
|
||||
{
|
||||
if(ah.override_gl_upload_caps)
|
||||
ah.override_gl_upload_caps();
|
||||
}
|
||||
|
||||
const OsPath& ah_get_log_dir()
|
||||
{
|
||||
return ah.get_log_dir();
|
||||
@@ -159,21 +112,6 @@ void ah_bundle_logs(FILE* f)
|
||||
ah.bundle_logs(f);
|
||||
}
|
||||
|
||||
const wchar_t* ah_translate(const wchar_t* text)
|
||||
{
|
||||
return ah.translate(text);
|
||||
}
|
||||
|
||||
void ah_translate_free(const wchar_t* text)
|
||||
{
|
||||
ah.translate_free(text);
|
||||
}
|
||||
|
||||
void ah_log(const wchar_t* text)
|
||||
{
|
||||
ah.log(text);
|
||||
}
|
||||
|
||||
ErrorReactionInternal ah_display_error(const wchar_t* text, size_t flags)
|
||||
{
|
||||
return ah.display_error(text, flags);
|
||||
|
||||
+2
-47
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -96,19 +96,6 @@ extern const wchar_t*, translate, (const wchar_t* text), (text), return)
|
||||
// trampolines for user code to call the hooks. they encapsulate
|
||||
// the details of how exactly to do this.
|
||||
|
||||
/**
|
||||
* override default decision on using OpenGL extensions relating to
|
||||
* texture upload.
|
||||
*
|
||||
* this should call ogl_tex_override to disable/force their use if the
|
||||
* current card/driver combo respectively crashes or
|
||||
* supports it even though the extension isn't advertised.
|
||||
*
|
||||
* the default implementation works but is hardwired in code and therefore
|
||||
* not expandable.
|
||||
**/
|
||||
extern void ah_override_gl_upload_caps();
|
||||
|
||||
/**
|
||||
* return path to directory into which crash dumps should be written.
|
||||
*
|
||||
@@ -131,34 +118,6 @@ extern const OsPath& ah_get_log_dir();
|
||||
**/
|
||||
extern void ah_bundle_logs(FILE* f);
|
||||
|
||||
/**
|
||||
* translate text to the current locale.
|
||||
*
|
||||
* @param text to translate.
|
||||
* @return pointer to localized text; must be freed via translate_free.
|
||||
*
|
||||
* the default implementation just returns the pointer unchanged.
|
||||
**/
|
||||
extern const wchar_t* ah_translate(const wchar_t* text);
|
||||
|
||||
/**
|
||||
* free text that was returned by translate.
|
||||
*
|
||||
* @param text to free.
|
||||
*
|
||||
* the default implementation does nothing.
|
||||
**/
|
||||
extern void ah_translate_free(const wchar_t* text);
|
||||
|
||||
/**
|
||||
* write text to the app's log.
|
||||
*
|
||||
* @param text to write.
|
||||
*
|
||||
* the default implementation uses stdout.
|
||||
**/
|
||||
extern void ah_log(const wchar_t* text);
|
||||
|
||||
/**
|
||||
* display an error dialog, thus overriding sys_display_error.
|
||||
*
|
||||
@@ -178,12 +137,8 @@ extern ErrorReactionInternal ah_display_error(const wchar_t* text, size_t flags)
|
||||
**/
|
||||
struct AppHooks
|
||||
{
|
||||
void (*override_gl_upload_caps)();
|
||||
const OsPath& (*get_log_dir)();
|
||||
void (*bundle_logs)(FILE* f);
|
||||
const wchar_t* (*translate)(const wchar_t* text);
|
||||
void (*translate_free)(const wchar_t* text);
|
||||
void (*log)(const wchar_t* text);
|
||||
ErrorReactionInternal (*display_error)(const wchar_t* text, size_t flags);
|
||||
};
|
||||
|
||||
@@ -206,4 +161,4 @@ extern bool app_hook_was_redefined(size_t offset_in_struct);
|
||||
// name is identifier of the function pointer within AppHooks to test.
|
||||
#define AH_IS_DEFINED(name) app_hook_was_redefined(offsetof(AppHooks, name))
|
||||
|
||||
#endif // #ifndef INCLUDED_APP_HOOKS
|
||||
#endif // INCLUDED_APP_HOOKS
|
||||
|
||||
@@ -339,7 +339,7 @@ fail:
|
||||
// implemented via sys_display_msg; see documentation there.
|
||||
void debug_DisplayMessage(const wchar_t* caption, const wchar_t* msg)
|
||||
{
|
||||
sys_display_msg(ah_translate(caption), ah_translate(msg));
|
||||
sys_display_msg(caption, msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -429,8 +429,6 @@ ErrorReaction debug_DisplayError(const wchar_t* description,
|
||||
return ER_CONTINUE;
|
||||
|
||||
// fix up params
|
||||
// .. translate
|
||||
description = ah_translate(description);
|
||||
// .. caller supports a suppress flag; set the corresponding flag so that
|
||||
// the error display implementation enables the Suppress option.
|
||||
if(suppress)
|
||||
|
||||
@@ -688,7 +688,7 @@ static int have_s3tc = -1;
|
||||
static int have_anistropy = -1;
|
||||
|
||||
// override the default decision and force/disallow use of the
|
||||
// given feature. should be called from ah_override_gl_upload_caps.
|
||||
// given feature.
|
||||
void ogl_tex_override(OglTexOverrides what, OglTexAllow allow)
|
||||
{
|
||||
ENSURE(allow == OGL_TEX_ENABLE || allow == OGL_TEX_DISABLE);
|
||||
@@ -743,21 +743,12 @@ static void detect_gl_upload_caps()
|
||||
have_anistropy = ogl_HaveExtension("GL_EXT_texture_filter_anisotropic");
|
||||
}
|
||||
|
||||
// allow app hook to make ogl_tex_override calls
|
||||
if(AH_IS_DEFINED(override_gl_upload_caps))
|
||||
{
|
||||
ah_override_gl_upload_caps();
|
||||
}
|
||||
// no app hook defined - have our own crack at blacklisting some hardware.
|
||||
else
|
||||
{
|
||||
const std::wstring cardName = gfx::CardName();
|
||||
// rationale: janwas's laptop's S3 card blows up if S3TC is used
|
||||
// (oh, the irony). it'd be annoying to have to share this between all
|
||||
// projects, hence this default implementation here.
|
||||
if(cardName == L"S3 SuperSavage/IXC 1014")
|
||||
ogl_tex_override(OGL_TEX_S3TC, OGL_TEX_DISABLE);
|
||||
}
|
||||
const std::wstring cardName = gfx::CardName();
|
||||
// rationale: janwas's laptop's S3 card blows up if S3TC is used
|
||||
// (oh, the irony). it'd be annoying to have to share this between all
|
||||
// projects, hence this default implementation here.
|
||||
if(cardName == L"S3 SuperSavage/IXC 1014")
|
||||
ogl_tex_override(OGL_TEX_S3TC, OGL_TEX_DISABLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ enum OglTexAllow
|
||||
|
||||
/**
|
||||
* Override the default decision and force/disallow use of the
|
||||
* given feature. Typically called from ah_override_gl_upload_caps.
|
||||
* given feature.
|
||||
*
|
||||
* @param what Feature to influence.
|
||||
* @param allow Disable/enable flag.
|
||||
|
||||
@@ -56,7 +56,7 @@ InputProcessor g_Input;
|
||||
double last_user_activity;
|
||||
|
||||
// see comment in GameLoop.cpp about ah_display_error before using INIT_HAVE_DISPLAY_ERROR
|
||||
const int g_InitFlags = INIT_HAVE_VMODE|INIT_NO_GUI;
|
||||
const int g_InitFlags = INIT_HAVE_VMODE | INIT_NO_GUI;
|
||||
|
||||
MESSAGEHANDLER(Init)
|
||||
{
|
||||
@@ -65,7 +65,7 @@ MESSAGEHANDLER(Init)
|
||||
g_Quickstart = true;
|
||||
|
||||
// Mount mods if there are any specified as command line parameters
|
||||
if (!Init(g_AtlasGameLoop->args, g_InitFlags | INIT_MODS|INIT_MODS_PUBLIC))
|
||||
if (!Init(g_AtlasGameLoop->args, g_InitFlags | INIT_MODS| INIT_MODS_PUBLIC))
|
||||
{
|
||||
// There are no mods specified on the command line,
|
||||
// but there are in the config file, so mount those.
|
||||
|
||||
Reference in New Issue
Block a user