Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Functions | Variables
app_hooks.cpp File Reference
#include "precompiled.h"
#include "lib/app_hooks.h"
#include "lib/sysdep/sysdep.h"
#include <cstdio>

Go to the source code of this file.

Macros

#define OVERRIDE_IF_NONZERO(HOOKNAME)   if(new_ah->HOOKNAME) ah.HOOKNAME = new_ah->HOOKNAME;
 

Functions

static void def_override_gl_upload_caps ()
 
static const OsPathdef_get_log_dir ()
 
static void def_bundle_logs (FILE *f)
 
static const wchar_tdef_translate (const wchar_t *text)
 
static void def_translate_free (const wchar_t *text)
 
static void def_log (const wchar_t *text)
 
static ErrorReactionInternal def_display_error (const wchar_t *text, size_t flags)
 
void app_hooks_update (AppHooks *new_ah)
 update the app hook function pointers. More...
 
bool app_hook_was_redefined (size_t offset_in_struct)
 was the app hook changed via app_hooks_update from its default value? More...
 
void ah_override_gl_upload_caps ()
 override default decision on using OpenGL extensions relating to texture upload. More...
 
const OsPathah_get_log_dir ()
 return path to directory into which crash dumps should be written. More...
 
void ah_bundle_logs (FILE *f)
 gather all app-related logs/information and write it to file. More...
 
const wchar_tah_translate (const wchar_t *text)
 translate text to the current locale. More...
 
void ah_translate_free (const wchar_t *text)
 free text that was returned by translate. More...
 
void ah_log (const wchar_t *text)
 write text to the app's log. More...
 
ErrorReactionInternal ah_display_error (const wchar_t *text, size_t flags)
 display an error dialog, thus overriding sys_display_error. More...
 

Variables

static AppHooks ah
 
static AppHooks default_ah = ah
 

Macro Definition Documentation

#define OVERRIDE_IF_NONZERO (   HOOKNAME)    if(new_ah->HOOKNAME) ah.HOOKNAME = new_ah->HOOKNAME;

Function Documentation

void ah_bundle_logs ( FILE *  f)

gather all app-related logs/information and write it to file.

used when writing a crash log so that all relevant info is in one file.

the default implementation attempts to gather 0ad data, but is fail-safe (doesn't complain if file not found).

Parameters
ffile into which to write.

Definition at line 156 of file app_hooks.cpp.

ErrorReactionInternal ah_display_error ( const wchar_t text,
size_t  flags 
)

display an error dialog, thus overriding sys_display_error.

Parameters
texterror message.
flagssee DebugDisplayErrorFlags.
Returns
ErrorReactionInternal.

the default implementation just returns ERI_NOT_IMPLEMENTED, which causes the normal sys_display_error to be used.

Definition at line 176 of file app_hooks.cpp.

const OsPath& ah_get_log_dir ( )

return path to directory into which crash dumps should be written.

must be callable at any time - in particular, before VFS init. paths are typically relative to sys_ExecutablePathname.

Returns
path ending with directory separator (e.g. '/').

Definition at line 151 of file app_hooks.cpp.

void ah_log ( const wchar_t text)

write text to the app's log.

Parameters
textto write.

the default implementation uses stdout.

Definition at line 171 of file app_hooks.cpp.

void ah_override_gl_upload_caps ( )

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.

Definition at line 145 of file app_hooks.cpp.

const wchar_t* ah_translate ( const wchar_t text)

translate text to the current locale.

Parameters
textto translate.
Returns
pointer to localized text; must be freed via translate_free.

the default implementation just returns the pointer unchanged.

Definition at line 161 of file app_hooks.cpp.

void ah_translate_free ( const wchar_t text)

free text that was returned by translate.

Parameters
textto free.

the default implementation does nothing.

Definition at line 166 of file app_hooks.cpp.

bool app_hook_was_redefined ( size_t  offset_in_struct)

was the app hook changed via app_hooks_update from its default value?

Parameters
offset_in_structbyte offset within AppHooks (determined via offsetof) of the app hook function pointer.

Definition at line 129 of file app_hooks.cpp.

void app_hooks_update ( AppHooks ah)

update the app hook function pointers.

Parameters
ahAppHooks struct. any of its function pointers that are non-zero override the previous function pointer value (these default to the stub hooks which are functional but basic).

Definition at line 115 of file app_hooks.cpp.

static void def_bundle_logs ( FILE *  f)
static

Definition at line 52 of file app_hooks.cpp.

static ErrorReactionInternal def_display_error ( const wchar_t text,
size_t  flags 
)
static

Definition at line 82 of file app_hooks.cpp.

static const OsPath& def_get_log_dir ( )
static

Definition at line 43 of file app_hooks.cpp.

static void def_log ( const wchar_t text)
static

Definition at line 69 of file app_hooks.cpp.

static void def_override_gl_upload_caps ( )
static

Definition at line 38 of file app_hooks.cpp.

static const wchar_t* def_translate ( const wchar_t text)
static

Definition at line 57 of file app_hooks.cpp.

static void def_translate_free ( const wchar_t text)
static

Definition at line 63 of file app_hooks.cpp.

Variable Documentation

AppHooks ah
static
Initial value:
=
{
}
static void def_translate_free(const wchar_t *text)
Definition: app_hooks.cpp:63
static const OsPath & def_get_log_dir()
Definition: app_hooks.cpp:43
static ErrorReactionInternal def_display_error(const wchar_t *text, size_t flags)
Definition: app_hooks.cpp:82
static void def_override_gl_upload_caps()
Definition: app_hooks.cpp:38
static void def_bundle_logs(FILE *f)
Definition: app_hooks.cpp:52
static const wchar_t * def_translate(const wchar_t *text)
Definition: app_hooks.cpp:57
static void def_log(const wchar_t *text)
Definition: app_hooks.cpp:69

Definition at line 96 of file app_hooks.cpp.

AppHooks default_ah = ah
static

Definition at line 110 of file app_hooks.cpp.